if (!$_GET['id']) { $html = file_get_contents("http://grouphug.us/random"); } else { if (!is_numeric($_GET['id'])) die("Invalid ID"); $html = file_get_contents("http://grouphug.us/confessions/".$_GET['id']); } $html = str_replace("\n", "", $html); preg_match("/(.*?)<\/td>/", $html, $quote); preg_match("/

(.*?)<\/h4>/", $html, $id); $conf = trim(strip_tags($quote[0])); $id = trim(strip_tags($id[0])); if (!$id || !$conf) die("ID does not exist"); echo $id." | ".$conf;