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)
{
if ( ! isset($reference[$segment]))
while (count($keys) > 1)
{
$reference[$segment] = $value;
$key = array_shift($keys);
return;
if ( ! isset($array[$key]))
{
$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