public function addItem($key, $item)
    {
        $dataset = $this->getDataset($key);

        // Get max value for the id
        $max = 0;
        foreach ($dataset as $val) {
            if ($max < $val["id"]) {
                $max = $val["id"];
            }
        }
        $item["id"] = $max + 1;
        $dataset[] = $item;
        $this->saveDataset($key, $dataset);
        return $item;
    }
public function addItem($key, $item)
    {
        $dataset = $this->getDataset($key);

        // Get max value for the id
        $max = 0;
        foreach ($dataset as $val) {
            if ($max < $val["id"]) {
                $max = $val["id"];
            }
        }
        $item["id"] = $max + 1;
        $dataset[] = $item;
        $this->saveDataset($key, $dataset);
        return $item;
    }
public function addItem ( $ key , $ item ) { $ dataset = $ this -> getDataset ( $ key ) ; // Get max value for the id $ max = 0 ; foreach ( $ dataset as $ val ) { if ( $ max < $ val [ "id" ] ) { $ max = $ val [ "id" ] ; } } $ item [ "id" ] = $ max + 1 ; $ dataset [ ] = $ item ; $ this -> saveDataset ( $ key , $ dataset ) ; return $ item ; }
Add an item to a dataset.

@param string $key  for the dataset
@param array  $item to add

@return array as new item inserted
Add an item to a dataset .