function testFileWriting($str) { $arr = array(1 => $str, "testkey" => "testvalue"); var_dump($arr); writeReservations($arr); print "test complete"; }
function checkOut($firstname, $lastname, $phone, $email) { if (!isset($_SESSION['cart'])) { return; } unset($_SESSION['receipt']); $arr = array("firstname" => $firstname, "lastname" => $lastname, "phone" => $phone, "email" => $email, "cart" => $_SESSION['cart']); $sum = 0; foreach ($_SESSION['cart'] as $k => $v) { foreach ($_SESSION['cart'][$k] as $k2 => $v2) { if ($k2 == "price") { $sum = $sum + (double) $v2; } } } writeReservations($arr); $_SESSION['receipt'] = array("firstname" => $firstname, "lastname" => $lastname, "phone" => $phone, "email" => $email, "cart" => $_SESSION['cart'], "sum" => $sum); unset($_SESSION['cart']); }