src/Util/JsonArray.php
public function get($path, $forceArray = false)
    {
        // special case, root element.
        if ($path === '/') {
            return $this->data;
        }

        $chunks = $this->splitPath($path);
        $scope  = $this->data;

        while (null !== ($sub = array_shift($chunks))) {
            if (isset($scope[$sub])) {
                if ($forceArray) {
                    $scope = (array) $scope[$sub];
                } else {
                    $scope = $scope[$sub];
                }
            } else {
                if ($forceArray) {
                    return [];
                } else {
                    return null;
                }
            }
        }
        return $scope;
    }
public function get($path, $forceArray = false)
    {
        // special case, root element.
        if ($path === '/') {
            return $this->data;
        }

        $chunks = $this->splitPath($path);
        $scope  = $this->data;

        while (null !== ($sub = array_shift($chunks))) {
            if (isset($scope[$sub])) {
                if ($forceArray) {
                    $scope = (array) $scope[$sub];
                } else {
                    $scope = $scope[$sub];
                }
            } else {
                if ($forceArray) {
                    return [];
                } else {
                    return null;
                }
            }
        }
        return $scope;
    }
public function get ( $ path , $ forceArray = false ) { // special case, root element. if ( $ path === '/' ) { return $ this -> data ; } $ chunks = $ this -> splitPath ( $ path ) ; $ scope = $ this -> data ; while ( null !== ( $ sub = array_shift ( $ chunks ) ) ) { if ( isset ( $ scope [ $ sub ] ) ) { if ( $ forceArray ) { $ scope = ( array ) $ scope [ $ sub ] ; } else { $ scope = $ scope [ $ sub ] ; } } else { if ( $ forceArray ) { return [ ] ; } else { return null ; } } } return $ scope ; }
Retrieve a value.

@param string $path       The path of the value.

@param bool   $forceArray Flag if the result shall be casted to array.

@return array|string|int|null
Retrieve a value .