I have a following array in PHP :
$myArray = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o"];
- I would like to insert a new element (e.g. 1 after every fourth element in the same array.
- Also, the array will start with 1.
The output will be:
$myTest = [1, "a", "b", "c", "d", 1, "e", "f", "g", "h", 1, "i", "j",
"k", "l", 1, "m", "n", "o"];
Note that in the above array, there is a 1 added after every 4th element.
Also, I am not adding the element just once. It is being added repeatedly after every 4th element until the end of the array.