Skip to content

Instantly share code, notes, and snippets.

@reshadman
Last active August 29, 2015 14:08
Show Gist options
  • Save reshadman/28bd5ed5888e2df5391d to your computer and use it in GitHub Desktop.
Save reshadman/28bd5ed5888e2df5391d to your computer and use it in GitHub Desktop.
<?php namespace Bigsinoos\Helpers;
class TreeFilter {
/**
* Get only some variables of a tow-level nested array
*
* @param $filterable
* @param array $keep
* @return array
*/
public static function doFilter(&$filterable, $keep = ['phone_number', 'leads'])
{
$keepable = [];
foreach($filterable as $key => $value){
foreach($keep as $what){
if(isset($value[$what])){
$keepable[$key][$what] = $value[$what];
}
}
}
$filterable = null;
return $keepable;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment