public static function set(array &$array, string $path, $value)
    {
        // Get segments from path
        $segments = explode('.', $path);

        // Loop through segments
        while (count($segments) > 1) {
            $segment = array_shift($segments);
            if (!isset($array[$segment]) || !is_array($array[$segment])) {
                $array[$segment] = [];
            }
            $array =& $array[$segment];
        }
        $array[array_shift($segments)] = $value;
    }
public static function set(array &$array, string $path, $value)
    {
        // Get segments from path
        $segments = explode('.', $path);

        // Loop through segments
        while (count($segments) > 1) {
            $segment = array_shift($segments);
            if (!isset($array[$segment]) || !is_array($array[$segment])) {
                $array[$segment] = [];
            }
            $array =& $array[$segment];
        }
        $array[array_shift($segments)] = $value;
    }
public static function set ( array & $ array , string $ path , $ value ) { // Get segments from path $ segments = explode ( '.' , $ path ) ; // Loop through segments while ( count ( $ segments ) > 1 ) { $ segment = array_shift ( $ segments ) ; if ( ! isset ( $ array [ $ segment ] ) || ! is_array ( $ array [ $ segment ] ) ) { $ array [ $ segment ] = [ ] ; } $ array = & $ array [ $ segment ] ; } $ array [ array_shift ( $ segments ) ] = $ value ; }
Sets an array value using "dot notation".

Arr::set($array, 'foo.bar', 'value');

@access  public
@param   array    $array  Array you want to modify
@param   string   $path   Array path
@param   mixed    $value  Value to set
Sets an array value using dot notation .