Created
June 26, 2013 09:40
-
-
Save TorbenKoehn/5866154 to your computer and use it in GitHub Desktop.
Polyfill for the PHP 5.4 array_column() function (untested)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Signature: array array_column ( array $input , mixed $column_key [, mixed $index_key ] ) | |
if( !function_exists( 'array_column' ) ): | |
function array_column( array $input, $column_key, $index_key = null ) { | |
$result = array(); | |
foreach( $input as $k => $v ) | |
$result[ $index_key ? $v[ $index_key ] : $k ] = $v[ $column_key ]; | |
return $result; | |
} | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use https://github.com/ramsey/array_column for proper replacement