src/Peekmo/JsonPath/JsonStore.php
public function get($expr, $unique = false)
    {
        if ((($exprs = $this->normalizedFirst($expr)) !== false) &&
            (is_array($exprs) || $exprs instanceof \Traversable)
        ) {
            $values = array();

            foreach ($exprs as $expr) {
                $o =& $this->data;
                $keys = preg_split(
                    "/([\"'])?\]\[([\"'])?/",
                    preg_replace(array("/^\\$\[[\"']?/", "/[\"']?\]$/"), "", $expr)
                );

                for ($i = 0; $i < count($keys); $i++) {
                    $o =& $o[$keys[$i]];
                }

                $values[] = & $o;
            }

            if (true === $unique) {
                if (!empty($values) && is_array($values[0])) {
                    array_walk($values, function(&$value) {
                        $value = json_encode($value);
                    });

                    $values = array_unique($values);
                    array_walk($values, function(&$value) {
                        $value = json_decode($value, true);
                    });

                    return array_values($values);
                }

                return array_unique($values);
            }

            return $values;
        }

        return self::$emptyArray;
    }
public function get($expr, $unique = false)
    {
        if ((($exprs = $this->normalizedFirst($expr)) !== false) &&
            (is_array($exprs) || $exprs instanceof \Traversable)
        ) {
            $values = array();

            foreach ($exprs as $expr) {
                $o =& $this->data;
                $keys = preg_split(
                    "/([\"'])?\]\[([\"'])?/",
                    preg_replace(array("/^\\$\[[\"']?/", "/[\"']?\]$/"), "", $expr)
                );

                for ($i = 0; $i < count($keys); $i++) {
                    $o =& $o[$keys[$i]];
                }

                $values[] = & $o;
            }

            if (true === $unique) {
                if (!empty($values) && is_array($values[0])) {
                    array_walk($values, function(&$value) {
                        $value = json_encode($value);
                    });

                    $values = array_unique($values);
                    array_walk($values, function(&$value) {
                        $value = json_decode($value, true);
                    });

                    return array_values($values);
                }

                return array_unique($values);
            }

            return $values;
        }

        return self::$emptyArray;
    }
public function get ( $ expr , $ unique = false ) { if ( ( ( $ exprs = $ this -> normalizedFirst ( $ expr ) ) !== false ) && ( is_array ( $ exprs ) || $ exprs instanceof \ Traversable ) ) { $ values = array ( ) ; foreach ( $ exprs as $ expr ) { $ o = & $ this -> data ; $ keys = preg_split ( "/([\"'])?\]\[([\"'])?/" , preg_replace ( array ( "/^\\$\[[\"']?/" , "/[\"']?\]$/" ) , "" , $ expr ) ) ; for ( $ i = 0 ; $ i < count ( $ keys ) ; $ i ++ ) { $ o = & $ o [ $ keys [ $ i ] ] ; } $ values [ ] = & $ o ; } if ( true === $ unique ) { if ( ! empty ( $ values ) && is_array ( $ values [ 0 ] ) ) { array_walk ( $ values , function ( & $ value ) { $ value = json_encode ( $ value ) ; } ) ; $ values = array_unique ( $ values ) ; array_walk ( $ values , function ( & $ value ) { $ value = json_decode ( $ value , true ) ; } ) ; return array_values ( $ values ) ; } return array_unique ( $ values ) ; } return $ values ; } return self :: $ emptyArray ; }
Gets elements matching the given JsonPath expression
@param string $expr JsonPath expression
@param bool $unique Gets unique results or not
@return array
Gets elements matching the given JsonPath expression