file)){ if (!$handle = fopen($this->file, 'a')){ echo "Cannot open file ($this->file)"; exit; } $post = $sub.':'.$date.':'.$author.':'.$content."\n"; if (fwrite($handle, $post) === FALSE){ echo "Cannot write to file ($this->file)"; exit; } fclose($handle); return true; } else { echo "File ($this->file) was not writable"; return false; } } public function getPosts($num){ $handle = fopen($this->file, 'r'); $posts = array(); if($handle){ for($i = 0; ($i <= ($num - 1)) && !feof($handle); $i++){ if($ipost = fgets($handle)){ $info = explode(':',$ipost); $posts[$i]['sub'] = $info[0]; $posts[$i]['date'] = $info[1]; $posts[$i]['author'] = $info[2]; $posts[$i]['content'] = $info[3]; } } } return $posts; } } ?>