3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(!function_exists('is_assoc')){ function is_assoc($array) { return (bool)count(array_filter(array_keys($array), 'is_string')); } } /** * getCols * * Takes an array of associative arrays and combines them to get * the columns * * @author Joe Richardson * @access public * @return object Instance of DB or Null */ function getCols(array $data) { if(is_assoc($data)){ return $data; }else{ return (array)call_user_func_array('array_merge_recursive',$data); } } $a = array( array( 'id' => 1 , 'name' => 'foo' , 'date' => date('m-d-Y') ) , array( 'id' => 2 , 'name' => 'bar' , 'date' => date('m-d-Y') ) , array( 'id' => 3 , 'name' => 'george' , 'date' => date('m-d-Y') ) , array( 'id' => 4 , 'name' => 'burdell' , 'date' => date('m-d-Y') ) ); $b = getCols($a); var_dump($b);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["id"]=> array(4) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) } ["name"]=> array(4) { [0]=> string(3) "foo" [1]=> string(3) "bar" [2]=> string(6) "george" [3]=> string(7) "burdell" } ["date"]=> array(4) { [0]=> string(10) "03-22-2013" [1]=> string(10) "03-22-2013" [2]=> string(10) "03-22-2013" [3]=> string(10) "03-22-2013" } }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.35 ms | 402 KiB | 8 Q