continued adding comments to arr class.
This commit is contained in:
parent
8711bb3d85
commit
7f5d047e1f
|
@ -42,6 +42,13 @@ public static function get($array, $key, $default = null)
|
||||||
*
|
*
|
||||||
* The same "dot" syntax used by the "get" method may be used here.
|
* The same "dot" syntax used by the "get" method may be used here.
|
||||||
*
|
*
|
||||||
|
* If no key is given to the method, the entire array will be replaced.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* // Set the $array['user']['name'] value on the array
|
||||||
|
* Arr::set($array, 'user.name', 'Taylor');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
|
@ -71,6 +78,14 @@ public static function set(&$array, $key, $value)
|
||||||
/**
|
/**
|
||||||
* Return the first element in an array which passes a given truth test.
|
* Return the first element in an array which passes a given truth test.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Return the first array element that equals "Taylor"
|
||||||
|
* $value = Arr::first($array, function($k, $v) {return $v === 'Taylor';});
|
||||||
|
*
|
||||||
|
* // Return a default value if no matching element is found
|
||||||
|
* $value = Arr::first($array, function($k, $v) {return $v === 'Taylor'}, 'Default');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param Closure $callback
|
* @param Closure $callback
|
||||||
* @return mixed
|
* @return mixed
|
||||||
|
@ -88,13 +103,21 @@ public static function first($array, $callback, $default = null)
|
||||||
/**
|
/**
|
||||||
* Remove all array values that are contained within a given array of values.
|
* Remove all array values that are contained within a given array of values.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Remove all array values that are empty strings
|
||||||
|
* $array = Arr::without($array, '');
|
||||||
|
*
|
||||||
|
* // Remove all array values that are "One", "Two", or "Three"
|
||||||
|
* $array = Arr::without($array, array('One', 'Two', 'Three'));
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param array $array
|
* @param array $array
|
||||||
* @param array $without
|
* @param array $without
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public static function without($array, $without = array())
|
public static function without($array, $without = array())
|
||||||
{
|
{
|
||||||
foreach ($array as $key => $value)
|
foreach ((array) $array as $key => $value)
|
||||||
{
|
{
|
||||||
if (in_array($value, $without)) unset($array[$key]);
|
if (in_array($value, $without)) unset($array[$key]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue