public static function dotSet(array $array, $key, $value)
    {
        $path = explode('.', $key);
        $total = count($path);

        $current = &$array;

        for ($ii = 0; $ii < $total; $ii++) {
            if ($ii === $total - 1) {
                $current[$path[$ii]] = $value;
            } else {
                if (!is_array($current)) {
                    throw new LackOfCoffeeException(
                        'Part of the path is not an array.'
                    );
                }

                if (!array_key_exists($path[$ii], $current)) {
                    $current[$path[$ii]] = [];
                }

                $current = &$current[$path[$ii]];
            }
        }
    }
public static function dotSet(array $array, $key, $value)
    {
        $path = explode('.', $key);
        $total = count($path);

        $current = &$array;

        for ($ii = 0; $ii < $total; $ii++) {
            if ($ii === $total - 1) {
                $current[$path[$ii]] = $value;
            } else {
                if (!is_array($current)) {
                    throw new LackOfCoffeeException(
                        'Part of the path is not an array.'
                    );
                }

                if (!array_key_exists($path[$ii], $current)) {
                    $current[$path[$ii]] = [];
                }

                $current = &$current[$path[$ii]];
            }
        }
    }
public static function dotSet ( array $ array , $ key , $ value ) { $ path = explode ( '.' , $ key ) ; $ total = count ( $ path ) ; $ current = & $ array ; for ( $ ii = 0 ; $ ii < $ total ; $ ii ++ ) { if ( $ ii === $ total - 1 ) { $ current [ $ path [ $ ii ] ] = $ value ; } else { if ( ! is_array ( $ current ) ) { throw new LackOfCoffeeException ( 'Part of the path is not an array.' ) ; } if ( ! array_key_exists ( $ path [ $ ii ] , $ current ) ) { $ current [ $ path [ $ ii ] ] = [ ] ; } $ current = & $ current [ $ path [ $ ii ] ] ; } } }
Set an array element using dot notation.

Same as `Arr::dotGet()`, but the value is replaced instead of fetched.

@param array $array
@param string $key
@param mixed $value

@throws LackOfCoffeeException
Set an array element using dot notation .