Extract values from an array with the given path.
@param array $arr
@param string|string[]|int $path
@return array
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;
    }
450326
public static function serialize(Path $path): array
    {
        $result = [];
        foreach ($path as $step) {
            $result[] = $step;
        }

        return $result;
    }
1205279
protected function readValues($data, array $paths)
    {
        $extracted = [];

        foreach ($paths as $index => $path) {
            $index = (string)$index;

            if (is_array($path)) {
                try {
                    $array = $this->accessor->getValue($data, $index);

                    if (!is_array($array) && !$array instanceof Traversable) {
                        $array = [$array];
                    }
                } catch (ExceptionInterface $e) {
                    $array = [];
                }

                $results = [];

                foreach ($array as $value) {
                    if ($path) {
                        $results[] = $this->readValues($value, $path);
                    } else {
                        if ($value = $this->convert($value)) {
                            $results[] = $value;
                        }
                    }
                }

                $extracted[$index] = $results;
            } else {
                $extracted[$index] = $this->readString($data, $path);
            }
        }

        return $extracted;
    }
1212568
public static function exists(array &$arr, $path, $delimiter = '.')
    {
        if (array_key_exists($path, $arr)) {
            return true;
        }

        $segments = explode($delimiter, $path);

        $cur = $arr;

        foreach ($segments as $segment) {
            if (! is_array($cur) or ! array_key_exists($segment, $cur)) {
                return false;
            }

            $cur = $cur[$segment];
        }

        return true;
    }
91131
public static function findDirs(string $path): array
    {
        $result = [];

        try {
            static::validatePath($path);
            $path = new DirectoryIterator($path);
        } catch (InvalidArgumentException $e) {
            return $result;
        } catch (UnexpectedValueException $e) {
            return $result;
        }

        foreach ($path as $dir) {
            if ($dir->isDot()) {
                continue;
            }
            if (!$dir->isDir()) {
                continue;
            }
            $result[] = $dir->getFilename();
        }
        asort($result);

        return $result;
    }
800010
protected function parsePath($path)
    {
        $path = ltrim($path, '/');
        foreach ($this->combinedResources as $resource) {
            if (strpos($path, $resource) !== false) {
                list($part1, $part2) = explode($resource, $path, 2);
                $parts = array_merge(explode('/', $part1), array($resource), explode('/', $part2));
                return array_values(array_filter($parts));
            }
        }
        return explode('/', $path);
    }
1085571
public static function getUnusedFiles(array $path): array
    {
        // load thumbnail files
        $thumbFiles = self::getThumbFiles();

        // load path files
        $pathFiles = self::getPathFiles($path);

        return $diff = array_diff($pathFiles, $thumbFiles);
    }
437947
protected function extractTranslationFromFile($path)
    {
        $result = [];
        $string = file_get_contents($path);

        foreach (array_flatten($this->config('trans_methods', [])) as $method) {
            preg_match_all($method, $string, $matches);

            foreach ($matches[1] as $k => $v) {
                if (strpos($v, '$') !== false) {
                    unset($matches[1][$k]);
                }
                if (strpos($v, '::') !== false) {
                    unset($matches[1][$k]);
                }
            }

            $result = array_merge($result, array_flip($matches[1]));
        }

        return $result;
    }
453710
public function own($path = ''): array
    {
        if ($path) {
            $parts = $this->split($path);
            $name = array_shift($parts);

            $own = [];
            if (isset($this->subTrees[$name])) {
                $subtree = $this->subTrees[$name];
                $this->appendChildren(
                    $own, $name, $subtree->own($parts)
                );
            }
        } else {
            $own = $this->ownData;
        }

        return $own;
    }
1017532
protected function split($path)
  {
    if (is_array($path)) {
      $parts = $path;
    } else {
      $parts = explode("/", $path);
    }
    return $parts;
  }
1101780
public static function get(array $array, string $path)
    {
        $paths = explode('.', $path);
        $temp = $array;
        while ($key = array_shift($paths)) {
            if (isset($temp[$key])) {
                $temp = $temp[$key];
            } else {
                return null;
            }
        }
        return $temp;
    }
738694
public static function array_delete(&$arr, $path) {
		if(!$path)
			return;
		if(!is_array($path))
			$path = [$path];
		$lastkey = array_pop($path);
		foreach($path as $parent)
			$arr =& $arr[$parent];
		unset($arr[$lastkey]);
	}
75051
public function getRedeemScriptByPath($path) {
        $walletScript = $this->getWalletScriptByPath($path);

        $redeemScript = $walletScript->isP2SH() ? $walletScript->getRedeemScript() : null;
        $witnessScript = $walletScript->isP2WSH() ? $walletScript->getWitnessScript() : null;
        return [$walletScript->getAddress()->getAddress(), $redeemScript, $witnessScript];
    }
870124
public static function extract(array $data, string $path)
    {
        if ('' === $path) {
            return $data;
        }

        $steps = explode('.', $path);
        $actual = $data;
        foreach ($steps as $step) {
            if (!array_key_exists($step, $actual)) {
                return null;
            }

            $actual = $actual[$step];
        }

        return $actual;
    }
808760
public function _pathAsArray($path)
    {
        $result = explode(self::PS, $path);
        // unset empty nodes
        foreach ($result as $key => $item) {
            if (!$item && $item !== "0") {
                unset($result[$key]);
            }
        }
        // re-index array
        $result = array_values($result);
        return $result;
    }
53474
public static function array_has($arr, $path) {
		if(!$path)
			return false;
		if(!is_array($path))
			$path = [$path];
		foreach($path as $key) {
			if(!isset($arr[$key]))
				return false;
			else
				$arr = $arr[$key];
		}
		return true;
	}
859390
public function getAsInstance($path)
    {
        if (empty($path)) {
            return static::create([], $this->separator);
        }
        $value = $this->getAsArray($path);
        if (!is_array($value)) {
            throw new \InvalidArgumentException('You cannot return a Parameter instance on a non-array value.');
        }
        return static::create($this->getAsArray($path), $this->separator);
    }