public static function delete($file, $keys) { function del(&$array, $recursive, $i) { if (array_key_exists($recursive[$i], $array)) { $y = $i + 1; if ($y == count($recursive)) { unset($array[$recursive[$i]]); return true; } elseif (is_array($array[$i])) { $i++; del($array[$i], $recursive, $i); } else { return false; // no need to continue farther } } } $array = Json::open($file); if ($array === false) { return false; } $test = del($array, $keys, 0); if ($test) { return Json::save($file, $array); } return false; }
public function init() { $this->content = Json::open($this->file); if ($this->content == false) { die('Couldn\'t open ticket file'); } }