If I have an array:
Array
(
[0] => H
[1] => e
[2] => l
[3] => l
[4] => o
[5] =>
[6] => F
[7] => r
[8] => i
[9] => e
[10] => n
[11] => d
)
And wanted to merge the values of the array based on the keys and end up with a new array of:
Array
(
[0] => Hell
[1] => o
[2] => Friend
)
Whats the best way of doing so with php?
use range() to get the pieces you want (
range()returns an array) and feed that array to implode() to merge the array into a string. (implode()returns a string).implode(range(0,3))should returnHell.doing the previous does not remove the
ellfrom their places. to remove other parts of the array, use unset()