I must be tired
Posted: Thu Nov 02, 2006 8:51 pm
I must really tired of this program I am writing. Currently I am trying to test some logic statements. Each time I end up having a problem I go back and make the program more and more basic. So now I am down to what should be a really simple program to write. And yet it doesn't work correctly What am I missing? Please - it must be something really obvious and I must be just exhausted because this is just not working.
function is called a little later. Currently $current_cart['date'] and $current_cart['cart'] both print to the screen but $cart_array['date']; and
$cart_array['cart']; do not. Shouldn't they. If I want to print an element from an array aren't I right in how to do this? Am I going crazy?
Code: Select all
$name = trim($_POST['name']);
$date = trim($_POST['date']);
$cart = trim($_POST['cart']);
$reservation = trim($_POST['reservation']);// this can have two values either reserve or cancel
//take the data from cartCheckoutInput.html page and create an arrary called $cart_array
$cart_array = array(
'name' => $name,
'date' => $date,
'cart' => $cart
);
//FUNCTIONS
//***************Cancel Function:**********************
// read the carts.txt file as an array
// create a new array that don't have: name.date.cart that user input
// replace the old carts.txt file with the new array
function cancel()
{
$file=file("carts.txt"); //grab carts.txt and store as an array. This array is serialized
foreach ($file as $line)
{
$my_line = trim($line);
$current_cart = unserialize($my_line);
echo $current_cart['date'];//prints fine
echo "<br />";
echo $cart_array['date'];//does not print
echo "<br />";
echo $current_cart['cart'];//prints fine
echo "<br />";
echo $cart_array['cart'];//does not print
echo "<br />";$cart_array['cart']; do not. Shouldn't they. If I want to print an element from an array aren't I right in how to do this? Am I going crazy?