Commit b2991dd6 authored by Taylor Otwell's avatar Taylor Otwell

Fix bug in Arr::set that did not correctly create new array levels.

parent 732a1e4a
......@@ -46,21 +46,21 @@ class Arr {
*/
public static function set(&$array, $key, $value)
{
$reference =& $array;
$keys = explode('.', $key);
foreach (explode('.', $key) as $segment)
while (count($keys) > 1)
{
if ( ! isset($reference[$segment]))
$key = array_shift($keys);
if ( ! isset($array[$key]))
{
$reference[$segment] = $value;
return;
$array[$key] = array();
}
$reference =& $reference[$segment];
$array =& $array[$key];
}
$reference = $value;
$array[array_shift($keys)] = $value;
}
}
\ No newline at end of file
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