Skip to content

Instantly share code, notes, and snippets.

@xikaos
Created February 6, 2018 18:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xikaos/b31850694aa4424813b93a0e768d339f to your computer and use it in GitHub Desktop.
Save xikaos/b31850694aa4424813b93a0e768d339f to your computer and use it in GitHub Desktop.
Shitty ".select" ruby method analog.
function filter_by_value ($array, $index, $value){
if(is_array($array) && count($array)>0)
{
foreach(array_keys($array) as $key){
$temp[$key] = $array[$key][$index];
if ($temp[$key] == $value){
$newarray[$key] = $array[$key];
}
}
}
return $newarray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment