Take a path of nested array with dot notation and build an array, saving it through reference.

@param  array $arr
@param  string $path
@param  string $value

@throws InvalidArgumentException
@throws TooManyNestedArraysException
555416
protected function assignArrayByDotPath(&$arr, string $path, string $value)
    {
        $keys = explode('.', $path);

        // Check that no key have a '0' value
        // This is because the '0' key is not read
        foreach ($keys as $keyValue) {
            if ($keyValue == '0') {
                throw new InvalidArgumentException('Invalid key in input array: part of the key in dot notation can NOT be \'0\'.');
            }
        }

        // Check if the allowed maximum level of nested array is exceeded
        $nestingLevels = count($keys);

        if ($nestingLevels > $this->allowedNestedArrays) {
            throw new TooManyNestedArraysException("Too many nested arrays in the input arrays. Maximum allowed is: " . $this->allowedNestedArrays);
        }

        while ($key = array_shift($keys)) {
            $arr = &$arr[$key];
        }

        $arr = $value;
    }
738563
public function set($path, $value)
    {
        PropertyAccessor::setByPath($this->values, $this->path($path), $value);
    }
104625
public <T> AsyncMutateInBuilder arrayInsert(String path, T value) {
        if (StringUtil.isNullOrEmpty(path)) {
            throw new IllegalArgumentException("Path must not be empty for arrayInsert");
        }
        this.mutationSpecs.add(new MutationSpec(Mutation.ARRAY_INSERT, path, value));
        return this;
    }
349767
public static function setValue(array $array, string $configPath, $value): array
    {
        if (!is_string($configPath) || $configPath === '') {
            throw new InvalidArgumentException('Path must be not be empty string', 1496472912);
        }
        // Extract parts of the configPath
        $path = str_getcsv($configPath, '.');
        // Point to the root of the array
        $pointer = &$array;
        // Find configPath in given array
        foreach ($path as $segment) {
            // Fail if the part is empty
            if ($segment === '') {
                throw new InvalidArgumentException('Invalid path segment specified', 1496472917);
            }
            // Create cell if it doesn't exist
            if (!array_key_exists($segment, $pointer)) {
                $pointer[$segment] = [];
            }
            // Set pointer to new cell
            $pointer = &$pointer[$segment];
        }
        // Set value of target cell
        $pointer = $value;

        return $array;
    }
548282
public static function set(array &$array, string $path, $value): void
    {
        $paths = explode('.', $path);
        $temp = &$array;
        while ($key = array_shift($paths)) {
            $temp = &$temp[$key];
        }
        $temp = $value;
    }
66359
protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
    {
        $validator = $this->factory->createInstanceFor('collection');
        $validator->check($value, $schema, $path, $i);

        $this->addErrors($validator->getErrors());
    }
354759
public function setValue($data, $keys, $value)
    {
        if ($this->isKeysEmpty($keys)) {
            return $data;
        }
        if (!is_array($keys)) {
            $keys = [$keys];
        }

        $accessor = new Accessor($data);
        $depth    = 0;
        $keyCount = count($keys);
        foreach ($keys as $key) {
            if ($depth + 1 === $keyCount) {
                if ($accessor->set($key, $value) === false) {
                    throw new InvalidArgumentException(sprintf(
                        'Did not set path %s in structure %s',
                        json_encode($keys),
                        json_encode($data)
                    ));
                }
            } elseif ($accessor->to($key) === false) {
                throw new InvalidArgumentException(sprintf(
                    'Did not find path %s in structure %s',
                    json_encode($keys),
                    json_encode($data)
                ));
            }

            ++$depth;
        }

        return $accessor->getData();
    }
13121
static protected function insertValueIntoStructureByPath(array $path, &$target, $value) {
		$segment = array_shift($path);
		if (count($path) > 0) {
			if (!array_key_exists($segment, $target)) {
				$target[$segment] = array();
			}
			self::insertValueIntoStructureByPath($path, $target[$segment], $value);
		} else {
			$target[$segment] = $value;
		}
		ksort($target);
	}
986672
function set(target, path, value) {
    if (path.length === 0) {
        return value;
    }
    return assign(Array.isArray(target) ? [] : {}, target, (_a = {},
        _a[path[0]] = path.length > 1 ? set(target[path[0]] || {}, path.slice(1), value) : value,
        _a));
    var _a;
}
862731
public static function setByPath(&$data, $path, $value, $separator = '.', $storeType = 'array')
	{
		$nodes = array_values(array_filter(explode($separator, $path), 'strlen'));

		if (empty($nodes))
		{
			return false;
		}

		/**
		 * A closure as inner function to create data store.
		 *
		 * @param string $type
		 *
		 * @return  array
		 *
		 * @throws \InvalidArgumentException
		 */
		$createStore = function($type)
		{
			if (strtolower($type) == 'array')
			{
				return array();
			}

			if (class_exists($type))
			{
				return new $type;
			}

			throw new \InvalidArgumentException(sprintf('Type or class: %s not exists', $type));
		};

		$dataTmp = &$data;

		foreach ($nodes as $node)
		{
			if (is_object($dataTmp))
			{
				if (empty($dataTmp->$node))
				{
					$dataTmp->$node = $createStore($storeType);
				}

				$dataTmp = &$dataTmp->$node;
			}
			elseif (is_array($dataTmp))
			{
				if (empty($dataTmp[$node]))
				{
					$dataTmp[$node] = $createStore($storeType);
				}

				$dataTmp = &$dataTmp[$node];
			}
			else
			{
				// If a node is value but path is not go to the end, we replace this value as a new store.
				// Then next node can insert new value to this store.
				$dataTmp = &$createStore($storeType);
			}
		}

		// Now, path go to the end, means we get latest node, set value to this node.
		$dataTmp = $value;

		return true;
	}
176230
public static function pluck($arr, $path) {
        $ret = [];
        $path = (array) $path;
        foreach($arr as $v) {
            $node = &$v;
            $ok = true;

            foreach($path as $part) {
                if(!is_array($node) || !array_key_exists($part, $node)) {
                    $ok = false;
                    break;
                }
                $node = &$node[$part];
            }

            if($ok) {
                $ret[] = $node;
            }
        }
        return $ret;
    }
1293486
public function set($path, $value)
    {
        $keys       = $this->explode($path);
        $parameters = &$this->parameters;

        while (count($keys) > 0) {
            if (count($keys) === 1) {
                if (!is_array($parameters)) {
                    $parameters = [];
                }
                $parameters[array_shift($keys)] = $value;
            } else {
                $key = array_shift($keys);
                if (!isset($parameters[$key])) {
                    $parameters[$key] = [];
                }
                $parameters = &$parameters[$key];
            }
        }
        return $this;
    }
34246
protected static function dotNotationToArray($string, $value, array &$array)
    {
        $keys = explode('.', $string);
        foreach ($keys as $key) {
            $array = &$array[$key];
        }
        $array = ($value === 'true' || $value === 'false') ? $value === 'true' : $value;
    }
5352
public function set($path, $value)
    {
        Arr::set($this->data, $path, $value);

        return true;
    }
176147
public static function set(array &$values, $path, $value)
    {
        if (is_array($path)) {
            // The path has already been separated into segments
            $segments = $path;
        } else {
            $path = (string) $path;

            // Remove starting delimiters and spaces
            $path = ltrim($path, sprintf('%s ', static::PATH_DELIMITER));
            // Remove ending delimiters, spaces, and wildcards
            $path = rtrim($path, sprintf('%s %s', static::PATH_DELIMITER, static::PATH_WILDCARD));
            // Split the segments by delimiter
            $segments = explode(static::PATH_DELIMITER, $path);
        }

        while (count($segments) > 1) {
            $key = array_shift($segments);

            /** @noinspection ReferenceMismatchInspection */
            if (!array_key_exists($key, $values) || !is_array($values[$key])) {
                $values[$key] = [];
            }

            $values =& $values[$key];
        }

        $values[array_shift($segments)] = $value;
    }
884784
protected function getArrayAttributeWithValue($path, $key, $value)
    {
        return array_set($this->getArrayAttributeByKey($key), str_replace('->', '.', $path), $value);
    }
599015
private function mapMultilang($value, array &$to)
    {
        $path = array_slice(func_get_args(), 2);
        while (count($path) >= 1) {
            $key = array_shift($path);
            if (!isset($to[$key])) {
                $to[$key] = array();
            }
            $to = &$to[$key];
        }
        $to = $value;
    }