3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function array_column( array $input, $columnKey, $indexKey=null ) { $arr = array(); if ( $indexKey !== null ) foreach ( $input as $val ) $arr[ $val[$indexKey] ] = $val[$columnKey]; else foreach ( $input as $val ) $arr[] = $val[$columnKey]; return $arr; } $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 5.3.0 - 5.4.13
array_column Fatal error: Call to undefined function array_columns() in /in/oKP6S on line 44
Process exited with code 255.