Skip to content

Instantly share code, notes, and snippets.

@TorbenKoehn
Created June 26, 2013 09:40
Show Gist options
  • Save TorbenKoehn/5866154 to your computer and use it in GitHub Desktop.
Save TorbenKoehn/5866154 to your computer and use it in GitHub Desktop.
Polyfill for the PHP 5.4 array_column() function (untested)
<?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;
@AlexSkrypnyk
Copy link

Use https://github.com/ramsey/array_column for proper replacement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment