src/Type/fixes/StdArray.php
function &select($query)
    {
        /**
         * @param $query
         * @param $stackArr
         * @return array|null
         */
        $_f__select = function & ($query, &$stackArr) use (&$_f__select)
        {
            $queryOrig = $query;
            if (strpos($query, '/') === 0)
                ## ignore first slash from instructions
                ## it cause an empty unwanted item on command stacks(exploded instructions)
                ## (withespace instruction has meaningful command "//item_on_any_depth")
                $query = substr($query, 1);

            if (!is_array($stackArr) && $query !== '') {
                // notice: only variable by reference must return
                $z = null;
                return $x = &$z;
            }


            if ($query === '')
                return $stackArr;

            $instructions = explode('/', $query);
            $ins          = array_shift($instructions);
            $remainQuery  = implode('/', $instructions);

            ## match find(//):
            if ($ins === '') {
                ### looking for any array elements to match query
                $return = array();
                foreach($stackArr as &$v) {
                    $r = &$_f__select($remainQuery, $v);
                    if ($r !== null)
                        $return[] = &$r;

                    if (is_array($v)) {
                        #### continue with deeper data
                        $r = &$_f__select($queryOrig, $v);
                        if ($r !== null) {
                            $return = array_merge($return, $r);
                        }
                    }
                }

                if (empty($return)) {
                    // notice: only variable by reference must return
                    $z = null;
                    return @$x = &$z;
                }

                return $return;
            }

            ## match wildcard:
            if ($ins === '*') {
                $return = array();
                foreach($stackArr as &$v)
                    $return[] = &$_f__select($remainQuery, $v);

                return $return;
            }

            ## match data item against current query instruct:
            if (array_key_exists($ins, $stackArr))
                ### looking for exact match of an item:
                ### /*/[query/to/match/item]
                return $_f__select($remainQuery, $stackArr[$ins]);
            else {
                ## nothing match query
                // notice: only variable by reference must return
                $z = null;
                return $x = &$z;
            }
        };

        return $_f__select($query, $this->value);
    }
function &select($query)
    {
        /**
         * @param $query
         * @param $stackArr
         * @return array|null
         */
        $_f__select = function & ($query, &$stackArr) use (&$_f__select)
        {
            $queryOrig = $query;
            if (strpos($query, '/') === 0)
                ## ignore first slash from instructions
                ## it cause an empty unwanted item on command stacks(exploded instructions)
                ## (withespace instruction has meaningful command "//item_on_any_depth")
                $query = substr($query, 1);

            if (!is_array($stackArr) && $query !== '') {
                // notice: only variable by reference must return
                $z = null;
                return $x = &$z;
            }


            if ($query === '')
                return $stackArr;

            $instructions = explode('/', $query);
            $ins          = array_shift($instructions);
            $remainQuery  = implode('/', $instructions);

            ## match find(//):
            if ($ins === '') {
                ### looking for any array elements to match query
                $return = array();
                foreach($stackArr as &$v) {
                    $r = &$_f__select($remainQuery, $v);
                    if ($r !== null)
                        $return[] = &$r;

                    if (is_array($v)) {
                        #### continue with deeper data
                        $r = &$_f__select($queryOrig, $v);
                        if ($r !== null) {
                            $return = array_merge($return, $r);
                        }
                    }
                }

                if (empty($return)) {
                    // notice: only variable by reference must return
                    $z = null;
                    return @$x = &$z;
                }

                return $return;
            }

            ## match wildcard:
            if ($ins === '*') {
                $return = array();
                foreach($stackArr as &$v)
                    $return[] = &$_f__select($remainQuery, $v);

                return $return;
            }

            ## match data item against current query instruct:
            if (array_key_exists($ins, $stackArr))
                ### looking for exact match of an item:
                ### /*/[query/to/match/item]
                return $_f__select($remainQuery, $stackArr[$ins]);
            else {
                ## nothing match query
                // notice: only variable by reference must return
                $z = null;
                return $x = &$z;
            }
        };

        return $_f__select($query, $this->value);
    }
function & select ( $ query ) { /**
         * @param $query
         * @param $stackArr
         * @return array|null
         */ $ _f__select = function & ( $ query , & $ stackArr ) use ( & $ _f__select ) { $ queryOrig = $ query ; if ( strpos ( $ query , '/' ) === 0 ) ## ignore first slash from instructions ## it cause an empty unwanted item on command stacks(exploded instructions) ## (withespace instruction has meaningful command "//item_on_any_depth") $ query = substr ( $ query , 1 ) ; if ( ! is_array ( $ stackArr ) && $ query !== '' ) { // notice: only variable by reference must return $ z = null ; return $ x = & $ z ; } if ( $ query === '' ) return $ stackArr ; $ instructions = explode ( '/' , $ query ) ; $ ins = array_shift ( $ instructions ) ; $ remainQuery = implode ( '/' , $ instructions ) ; ## match find(//): if ( $ ins === '' ) { ### looking for any array elements to match query $ return = array ( ) ; foreach ( $ stackArr as & $ v ) { $ r = & $ _f__select ( $ remainQuery , $ v ) ; if ( $ r !== null ) $ return [ ] = & $ r ; if ( is_array ( $ v ) ) { #### continue with deeper data $ r = & $ _f__select ( $ queryOrig , $ v ) ; if ( $ r !== null ) { $ return = array_merge ( $ return , $ r ) ; } } } if ( empty ( $ return ) ) { // notice: only variable by reference must return $ z = null ; return @ $ x = & $ z ; } return $ return ; } ## match wildcard: if ( $ ins === '*' ) { $ return = array ( ) ; foreach ( $ stackArr as & $ v ) $ return [ ] = & $ _f__select ( $ remainQuery , $ v ) ; return $ return ; } ## match data item against current query instruct: if ( array_key_exists ( $ ins , $ stackArr ) ) ### looking for exact match of an item: ### /*/[query/to/match/item] return $ _f__select ( $ remainQuery , $ stackArr [ $ ins ] ) ; else { ## nothing match query // notice: only variable by reference must return $ z = null ; return $ x = & $ z ; } } ; return $ _f__select ( $ query , $ this -> value ) ; }
Select Bunch Of Items Regard To Given Query

!! for reference return must call with reference
&$stdArr->select('/1/Passenger/Credentials');

$result->select('/* /Passengers');
mean from root-any key presentation - that contains Passenger

$result->select('/insurance|hotels/Passengers');
mean from root-insurance|hotels-that contains Passenger

@param string $query

@return &mixed
Select Bunch Of Items Regard To Given Query