Skip to content

Instantly share code, notes, and snippets.

@erowsika
Last active December 22, 2021 13:34
Show Gist options
  • Save erowsika/0d12906f767c375d1b489c0185c2a14c to your computer and use it in GitHub Desktop.
Save erowsika/0d12906f767c375d1b489c0185c2a14c to your computer and use it in GitHub Desktop.
<?php
// copied from https://raw.githubusercontent.com/DataTables/DataTables/master/examples/server_side/scripts/ssp.class.php
function array_pluck($a, $prop)
{
$out = array();
for ( $i=0, $len=count($a) ; $i<$len ; $i++ ) {
if(empty($a[$i][$prop])){
continue;
}
//removing the $out array index confuses the filter method in doing proper binding,
//adding it ensures that the array data are mapped correctly
$out[$i] = $a[$i][$prop];
}
return $out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment