Anyone know how I can return every other element from an array?
For example:
$numbers = array('1','2','3','4','5','6');
I want to return:
'1', '3', '5'
I'm playing with array_splice, but I haven't figured it out yet. :bemused:
for($i = 0; $i < count($startArray); $i++) if(($i % 2) == 1) // 0 for even elements $endArray[] = $startArray[$i];