I have this array:
$array = array(a, b, c, d, e, f, g);
I want to split it in two arrays depending if the index is even or odd, like this:<
I am not sure if this is the most elegant way, but it should work a charm:
$odd=array(); $even=array(); $count=1; foreach($array as $val) { if($count%2==1) { $odd[]=$val; } else { $even[]=$val; } $count++; }