Foundation/Collection.php
public function set($key, $value, $dot_syntax = true)
    {
        if ($dot_syntax === true) {

            $paths = explode('.', $key);
            $pathCount = count($paths);
            $currentIteration = 0;
            $node =& $this->_data;
            foreach ($paths as $path) {
                if (isset($node[$path])) {
                    $node =& $node[$path];
                    $currentIteration++;
                } elseif($currentIteration < $pathCount) {
                    $node[$path] = array();
                    $node =& $node[$path];
                    $currentIteration++;
                }
            }
            
            $node = $value;
            
        } else {
            
            $this->_data[$key] = $value;
            
        }

        return $this;
    }
public function set($key, $value, $dot_syntax = true)
    {
        if ($dot_syntax === true) {

            $paths = explode('.', $key);
            $pathCount = count($paths);
            $currentIteration = 0;
            $node =& $this->_data;
            foreach ($paths as $path) {
                if (isset($node[$path])) {
                    $node =& $node[$path];
                    $currentIteration++;
                } elseif($currentIteration < $pathCount) {
                    $node[$path] = array();
                    $node =& $node[$path];
                    $currentIteration++;
                }
            }
            
            $node = $value;
            
        } else {
            
            $this->_data[$key] = $value;
            
        }

        return $this;
    }
public function set ( $ key , $ value , $ dot_syntax = true ) { if ( $ dot_syntax === true ) { $ paths = explode ( '.' , $ key ) ; $ pathCount = count ( $ paths ) ; $ currentIteration = 0 ; $ node = & $ this -> _data ; foreach ( $ paths as $ path ) { if ( isset ( $ node [ $ path ] ) ) { $ node = & $ node [ $ path ] ; $ currentIteration ++ ; } elseif ( $ currentIteration < $ pathCount ) { $ node [ $ path ] = array ( ) ; $ node = & $ node [ $ path ] ; $ currentIteration ++ ; } } $ node = $ value ; } else { $ this -> _data [ $ key ] = $ value ; } return $ this ; }
Stores an item in the collection at the designated key.
Dot syntax can be used to nest data in the array.

@param string $key
@param mixed $value
@return \m\Foundation\Collection
Stores an item in the collection at the designated key . Dot syntax can be used to nest data in the array .