function parseDirections($in) { $arr = array(); $x = 0; $y = 0; $arr = addToArr($x, $y, $arr); for ($i = 0; $i < strlen($in); $i++) { $instruction = substr($in, $i, 1); switch ($instruction) { case "^": $y--; break; case "v": $y++; break; case ">": $x++; break; case "<": $x--; break; default: die("Unrecognised instruction"); } $arr = addToArr($x, $y, $arr); } $count = 0; foreach ($arr as $row) { foreach ($row as $col) { $count++; } } echo "Houses: {$count}\n"; }
if (count($qarr) != 0) { $t = implode(" AND ", $qarr); $query .= " AND " . $t; } $q = $conn->query($query); if ($q->num_rows != 0) { while ($r = $q->fetch_assoc()) { $id = $r['id']; $occ = $r['dl']; addScore($id, 5 + $occ / 200); } } $qarr = array(); addToArr("notes.sch", $usersch); addToArr("notes.lvl", $userlvl); addToArr("notes.subj", $usersubj); if (count($qarr) != 0) { $t = implode(" AND ", $qarr); } $warr = explode(" ", $userq); foreach ($warr as $x) { $query = "SELECT indextable.notesid, indextable.occurrence\r\n\t\t FROM indextable INNER JOIN notes ON indextable.notesid = notes.id\r\n\t\t WHERE indextable.word = '{$x}' "; if (isset($t)) { $query .= " AND " . $t; } $q = $conn->query($query); if ($q->num_rows != 0) { while ($r = $q->fetch_assoc()) { $id = $r['indextable.notesid']; $occ = $r['indextable.occurrence']; addScore($id, 1 + $occ / 100);