X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FUtils%2FArray.php;h=f4938febf89bfe95ae21931c55d724e10b18a98b;hb=f58d84b73435283fbd3d34c1ce06e2d6c7000b70;hp=4829078fc043dabbe7eceacc001bc6c5abf894e4;hpb=b48045a740f9b4b47c9f320616baf8ea1f3e2c04;p=civicrm-core.git diff --git a/CRM/Utils/Array.php b/CRM/Utils/Array.php index 4829078fc0..f4938febf8 100644 --- a/CRM/Utils/Array.php +++ b/CRM/Utils/Array.php @@ -1197,4 +1197,20 @@ class CRM_Utils_Array { return $array; } + /** + * Append the value to the array using the key provided. + * + * e.g if value is 'llama' & path is [0, 'email', 'location'] result will be + * [0 => ['email' => ['location' => 'llama']] + * + * @param $path + * @param $value + * + * @return array + */ + public static function recursiveBuild($path, $value) { + $arrayKey = array_shift($path); + return [$arrayKey => (empty($path) ? $value : self::recursiveBuild($path, $value))]; + } + }