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, $col = NULL) { if(is_assoc($data)){ $d = $data; }else{ $d = (array)call_user_func_array('array_merge_recursive',$data); } return ($col === NULL)?$d:$d[$col]; } $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') ) ); if(function_exists('array_column')) { echo('array_column '); $b = array_columns($a, 'name'); }else { echo('getCols '); $b = getCols($a, 'name'); } var_dump($b);
Output for git.master, git.master_jit, rfc.property-hooks
array_column Fatal error: Uncaught Error: Call to undefined function array_columns() in /in/tvgoD:60 Stack trace: #0 {main} thrown in /in/tvgoD on line 60
Process exited with code 255.

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:
44.21 ms | 401 KiB | 8 Q