Skip to content

Commit

Permalink
Avoid PHP error if property name is empty in ArrayHelper::toObject()
Browse files Browse the repository at this point in the history
  • Loading branch information
cheesegrits committed Apr 29, 2019
1 parent 9780bb3 commit cb0e809
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions libraries/fabrik/fabrik/Helpers/ArrayHelper.php
Expand Up @@ -152,13 +152,17 @@ public static function toObject(&$array, $class = 'stdClass', $recurse = true)

foreach ($array as $k => $v)
{
if (is_array($v) && $recurse)
// avoid PHP error if property name is empty
if ($k !== '')
{
$obj->$k = self::toObject($v, $class);
}
else
{
$obj->$k = $v;
if (is_array($v) && $recurse)
{
$obj->$k = self::toObject($v, $class);
}
else
{
$obj->$k = $v;
}
}
}
}
Expand Down

0 comments on commit cb0e809

Please sign in to comment.