Commit 28c6ac93 by Taylor Otwell

Scrap Arr::dot and put dot notation support in Arr::get.

parent db5c61d5
......@@ -5,7 +5,8 @@ class Arr {
/**
* Get an item from an array.
*
* If the specified key is null, the entire array will be returned.
* If the specified key is null, the entire array will be returned. The array may
* also be accessed using JavaScript "dot" style notation.
*
* @param array $array
* @param string $key
......@@ -19,29 +20,6 @@ class Arr {
return $array;
}
if (array_key_exists($key, $array))
{
return $array[$key];
}
return is_callable($default) ? call_user_func($default) : $default;
}
/**
* Get an item from an array using JavaScript style "dot" notation.
*
* @param array $array
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function dot($array, $key, $default = null)
{
if (is_null($key))
{
return $array;
}
foreach (explode('.', $key) as $segment)
{
if ( ! isset($array[$segment]))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment