public static function set(&$array, $key, $value)
    {
        $key = static::normalizeKey($key);

        if ($key === null || $key === '')
        {
            return ($array = $value);
        }

        $keys = explode('.', $key);
        $last = array_pop($keys);
        $currentElement =& $array;

        foreach ($keys as $currentKey)
        {
            if (!array_key_exists($currentKey, $currentElement) || !is_array($currentElement[$currentKey]))
            {
                $currentElement[$currentKey] = [];
            }

            $currentElement =& $currentElement[$currentKey];
        }

        $currentElement[$last] = $value;

        return $array;
    }
public static function set(&$array, $key, $value)
    {
        $key = static::normalizeKey($key);

        if ($key === null || $key === '')
        {
            return ($array = $value);
        }

        $keys = explode('.', $key);
        $last = array_pop($keys);
        $currentElement =& $array;

        foreach ($keys as $currentKey)
        {
            if (!array_key_exists($currentKey, $currentElement) || !is_array($currentElement[$currentKey]))
            {
                $currentElement[$currentKey] = [];
            }

            $currentElement =& $currentElement[$currentKey];
        }

        $currentElement[$last] = $value;

        return $array;
    }
public static function set ( & $ array , $ key , $ value ) { $ key = static :: normalizeKey ( $ key ) ; if ( $ key === null || $ key === '' ) { return ( $ array = $ value ) ; } $ keys = explode ( '.' , $ key ) ; $ last = array_pop ( $ keys ) ; $ currentElement = & $ array ; foreach ( $ keys as $ currentKey ) { if ( ! array_key_exists ( $ currentKey , $ currentElement ) || ! is_array ( $ currentElement [ $ currentKey ] ) ) { $ currentElement [ $ currentKey ] = [ ] ; } $ currentElement = & $ currentElement [ $ currentKey ] ; } $ currentElement [ $ last ] = $ value ; return $ array ; }
Set the value for given key in the array with dot notation support.

@param array &$array
@param string $key
@param mixed $value
@return array
Set the value for given key in the array with dot notation support .