I have an multidimensional array:
array( array(925, 1) array(605, 5) array(858, 7) )
I want to split it into two arrays:
array(925,605,858) array(1,5,7)
How would I do that?
Have a look at Example 3 of [man]array_filter[/man]
There is no example 3.
I looked through everything else and that seems to search an array for specific criteria. This array will be dynamic and from a database, so I have no way of filtering specific data.
I need to simply seperate the sub-array values by there key.
I just spent some time and figured it out, it was much easier than I thought.
$array1 = array( array(949, 1), array(626, 8), array(520, 9) ); $i = 1; foreach($array1 as $value){ foreach($value as $key => $value2){ if($i % 2){ $tmpArray1 = array($value2); $acArray = array_merge($acArray, $tmpArray1); } else { $tmpArray2 = array($value2); $ctArray = array_merge($ctArray, $tmpArray2); } ++$i; } }
foreach ($array1 as $value) { $acArray[] = $value[0]; $ctArray[] = $value[1]; }
Originally posted by viveleroi0 There is no example 3.
My mistake; [man]array_map[/man]