Flow\JSONPath\JSONPath::offsetGet PHP Method

offsetGet() public method

public offsetGet ( $offset )
    public function offsetGet($offset)
    {
        $value = AccessHelper::getValue($this->data, $offset);
        return AccessHelper::isCollectionType($value) ? new static($value, $this->options) : $value;
    }

Usage Example

示例#1
0
 public function testOffsetUnset()
 {
     $data = array("route" => array(array("name" => "A", "type" => "type of A"), array("name" => "B", "type" => "type of B")));
     $data = json_encode($data);
     $jsonIterator = new JSONPath(json_decode($data));
     /** @var JSONPath $route */
     $route = $jsonIterator->offsetGet('route');
     $route->offsetUnset(0);
     $first = $route->first();
     $this->assertEquals("B", $first['name']);
 }