public static function set(array &$array, $keyPath, $value)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $keys = self::explodeKeys(strval($keyPath));
        $result = $array;
        $ptr = &$result;

        $parentKeys = array();
        while ($keys !== array()) {
            $key = array_shift($keys);
            $parentKeys[] = $key;

            if (!array_key_exists($key, $ptr)) {
                $ptr[$key] = $keys === array() ? $value : array();
                $ptr = &$ptr[$key];
                continue;
            }
            $ptr = &$ptr[$key];
            if ($keys === array()) {
                $ptr = $value;
                break;
            }
            elseif (!is_array($ptr)) {
                throw new InconsistentKeyTypes($ptr, array(), implode('.', $parentKeys));
            }
        }

        $array = $result;
    }
public static function set(array &$array, $keyPath, $value)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $keys = self::explodeKeys(strval($keyPath));
        $result = $array;
        $ptr = &$result;

        $parentKeys = array();
        while ($keys !== array()) {
            $key = array_shift($keys);
            $parentKeys[] = $key;

            if (!array_key_exists($key, $ptr)) {
                $ptr[$key] = $keys === array() ? $value : array();
                $ptr = &$ptr[$key];
                continue;
            }
            $ptr = &$ptr[$key];
            if ($keys === array()) {
                $ptr = $value;
                break;
            }
            elseif (!is_array($ptr)) {
                throw new InconsistentKeyTypes($ptr, array(), implode('.', $parentKeys));
            }
        }

        $array = $result;
    }
public static function set ( array & $ array , $ keyPath , $ value ) { self :: checkKeyPathIsValidAndNonEmpty ( $ keyPath ) ; $ keys = self :: explodeKeys ( strval ( $ keyPath ) ) ; $ result = $ array ; $ ptr = & $ result ; $ parentKeys = array ( ) ; while ( $ keys !== array ( ) ) { $ key = array_shift ( $ keys ) ; $ parentKeys [ ] = $ key ; if ( ! array_key_exists ( $ key , $ ptr ) ) { $ ptr [ $ key ] = $ keys === array ( ) ? $ value : array ( ) ; $ ptr = & $ ptr [ $ key ] ; continue ; } $ ptr = & $ ptr [ $ key ] ; if ( $ keys === array ( ) ) { $ ptr = $ value ; break ; } elseif ( ! is_array ( $ ptr ) ) { throw new InconsistentKeyTypes ( $ ptr , array ( ) , implode ( '.' , $ parentKeys ) ) ; } } $ array = $ result ; }
Set the dotted key path in the array.

@param array $array
@param string $keyPath
@param mixed $value The value to set in the array.

@return void
@throws BadKeyPath
@throws InconsistentKeyTypes
Set the dotted key path in the array .