I have an array:
Array ( [A] => 4 [B] => 4 [D] => 4 [E] => 8 [F] => 4 [G] => 8 [H] => 8 [J] => 12 [K] => 12 [L] => 11 [M] => 11 [O] => 10 [P] => 10 [Q] => 10 [R] => 10 )
It had more values, but I filtered out the zero values, because I don't need them.
Now I need every other value, so that I get:
Array ( [A] => 4 [D] => 4 [F] => 4 [H] => 8 [K] => 12 [M] => 11 [P] => 10 [R] => 10 )
I also need the remaining array with the keys intact
Array ( [B] => 4 [E] => 8 [G] => 8 [J] => 12 [L] => 11 [O] => 10 [Q] => 10 )
How can I possibly do this?
The length of the array is subjectible to change. Also the zero values can change.
Try as
Using
array_walk
functionFiddle
Fiddle(array_walk)