Last active
August 29, 2015 14:08
-
-
Save reshadman/28bd5ed5888e2df5391d to your computer and use it in GitHub Desktop.
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 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