more refactoring for 2.0

This commit is contained in:
Taylor Otwell
2011-09-19 21:33:25 -05:00
parent 7898094e25
commit a8dbe777df
13 changed files with 505 additions and 136 deletions

View File

@@ -110,4 +110,29 @@ class Arr {
return ($default instanceof \Closure) ? call_user_func($default) : $default;
}
/**
* Remove all values in the array that are contained within a given array of values.
*
* <code>
* // Remove all empty string values from an array
* $array = Arr::without($array, array(''));
*
* // Remove all array values that are "3", "2", or "1"
* $array = Arr::without($array, array(3, 2, 1));
* </code>
*
* @param array $array
* @param array $without
* @return array
*/
public static function without($array, $without = array())
{
foreach ($array as $key => $value)
{
if (in_array($value, $without)) unset($array[$key]);
}
return $array;
}
}