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
@fedir: It's some kind of templating style if you put it as that, I just want to keep curly brackets out of the global scope just as in templates.
It has no deeper meaning, it was more an emotional thing, do it as you like of course
Also, sorry for the late answer hehe :)