How can I efficiently split an array into its associative key arrays?
How can I split a single array into it's sub-keys? $arr = array( 0 => array( 'foo' => '1', 'bar' => 'A' ), 1 => array( 'foo' => '2', 'bar' => 'B' ), 2 => array( 'foo' => '3', 'bar' => 'C' ) ); What is the most efficient way to return an array of foo and bar separately? I need to get here: $foo = array('1','2','3'); $bar = array('A','B','C'); I'm hoping there's a clever way to do this using array_map or something similar. Any ideas? Or do I have to loop through and build each array that way? Something like: foreach ($arr as $v) { $foo[] = $v['foo']; $bar[] = $v['bar']; } In a lucky coincidence,