public function readVarInto($varstr, $data, $safeRead = false)
    {
        if ($data === null) {
            return null;
        }

        if (is_array($varstr) === false) {
            preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
        } else {
            $m = $varstr;
        }
        unset($varstr);

        foreach ($m[1] as $k => $sep) {
            if ($sep === '.' || $sep === '[' || $sep === '') {
                // strip enclosing quotes if present
                $m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]);

                if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) {
                    $data = $data[$m[2][$k]];
                } else {
                    return null;
                }
            } else {
                if (is_object($data) && ($safeRead === false || isset($data->{$m[2][$k]}))) {
                    $data = $data->{$m[2][$k]};
                } else {
                    return null;
                }
            }
        }

        return $data;
    }
public function readVarInto($varstr, $data, $safeRead = false)
    {
        if ($data === null) {
            return null;
        }

        if (is_array($varstr) === false) {
            preg_match_all('#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i', $varstr, $m);
        } else {
            $m = $varstr;
        }
        unset($varstr);

        foreach ($m[1] as $k => $sep) {
            if ($sep === '.' || $sep === '[' || $sep === '') {
                // strip enclosing quotes if present
                $m[2][$k] = preg_replace('#^(["\']?)(.*?)\1$#', '$2', $m[2][$k]);

                if ((is_array($data) || $data instanceof ArrayAccess) && ($safeRead === false || isset($data[$m[2][$k]]))) {
                    $data = $data[$m[2][$k]];
                } else {
                    return null;
                }
            } else {
                if (is_object($data) && ($safeRead === false || isset($data->{$m[2][$k]}))) {
                    $data = $data->{$m[2][$k]};
                } else {
                    return null;
                }
            }
        }

        return $data;
    }
public function readVarInto ( $ varstr , $ data , $ safeRead = false ) { if ( $ data === null ) { return null ; } if ( is_array ( $ varstr ) === false ) { preg_match_all ( '#(\[|->|\.)?((?:[^.[\]-]|-(?!>))+)\]?#i' , $ varstr , $ m ) ; } else { $ m = $ varstr ; } unset ( $ varstr ) ; foreach ( $ m [ 1 ] as $ k => $ sep ) { if ( $ sep === '.' || $ sep === '[' || $ sep === '' ) { // strip enclosing quotes if present $ m [ 2 ] [ $ k ] = preg_replace ( '#^(["\']?)(.*?)\1$#' , '$2' , $ m [ 2 ] [ $ k ] ) ; if ( ( is_array ( $ data ) || $ data instanceof ArrayAccess ) && ( $ safeRead === false || isset ( $ data [ $ m [ 2 ] [ $ k ] ] ) ) ) { $ data = $ data [ $ m [ 2 ] [ $ k ] ] ; } else { return null ; } } else { if ( is_object ( $ data ) && ( $ safeRead === false || isset ( $ data -> { $ m [ 2 ] [ $ k ] } ) ) ) { $ data = $ data -> { $ m [ 2 ] [ $ k ] } ; } else { return null ; } } } return $ data ; }
Reads a variable into the given data array.

@param string $varstr   the variable string, using dwoo variable syntax (i.e. "var.subvar[subsubvar]->property")
@param mixed  $data     the data array or object to read from
@param bool   $safeRead if true, the function will check whether the index exists to prevent any notices from
being output

@return mixed
Reads a variable into the given data array .