src/Peekmo/JsonPath/JsonStore.php
public function add($parentexpr, $value, $name = "")
    {
        $get = $this->get($parentexpr);
        if ($parents =& $get) {

            foreach ($parents as &$parent) {
                $parent = is_array($parent) ? $parent : array();

                if ($name != "") {
                    $parent[$name] = $value;
                } else {
                    $parent[] = $value;
                }
            }

            return true;
        }

        return false;
    }
public function add($parentexpr, $value, $name = "")
    {
        $get = $this->get($parentexpr);
        if ($parents =& $get) {

            foreach ($parents as &$parent) {
                $parent = is_array($parent) ? $parent : array();

                if ($name != "") {
                    $parent[$name] = $value;
                } else {
                    $parent[] = $value;
                }
            }

            return true;
        }

        return false;
    }
public function add ( $ parentexpr , $ value , $ name = "" ) { $ get = $ this -> get ( $ parentexpr ) ; if ( $ parents = & $ get ) { foreach ( $ parents as & $ parent ) { $ parent = is_array ( $ parent ) ? $ parent : array ( ) ; if ( $ name != "" ) { $ parent [ $ name ] = $ value ; } else { $ parent [ ] = $ value ; } } return true ; } return false ; }
Adds one or more elements matching the given json path expression
@param string $parentexpr JsonPath expression to the parent
@param mixed $value Value to add
@param string $name Key name
@return bool returns true if success
Adds one or more elements matching the given json path expression