src/Util.php
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;
    }
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;
    }
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 ; }
Extract values from an array with the given path.
@param array $arr
@param string|string[]|int $path
@return array
Extract values from an array with the given path .