Create array if not existing

This commit is contained in:
Dennis Eichhorn 2018-08-28 20:17:22 +02:00 committed by GitHub
parent a022348e47
commit a37dd5e792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -96,8 +96,16 @@ final class ArrayUtils
throw new \Exception(); throw new \Exception();
} }
$pathPartCount = \count($pathParts);
$c = 1;
foreach ($pathParts as $key) { foreach ($pathParts as $key) {
if (!isset($current[$key]) && $pathPartCount < $c) {
$current = [];
}
$current = &$current[$key]; $current = &$current[$key];
++$c;
} }
if ($overwrite) { if ($overwrite) {