gavin1512 Posted January 4, 2008 Share Posted January 4, 2008 Good Day All, I am surrently working on an internal order system, I am able to write the items to my array called 'order' but my code for removing from an array is not working at all and just goes straight to the header. Here is the code I am using. <?php session_start(); foreach($_SESSION['order'] as $key => $product){ if ($_SESSION['order'][$key]['productnumber'] == $_GET['productnumber']){ unset($_SESSION['order'][$key]); } } header("Location: productsearch.php"); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/84499-remove-item-from-an-array/ Share on other sites More sharing options...
sKunKbad Posted January 4, 2008 Share Posted January 4, 2008 unset($_SESSION['order'][$key]['productnumber']); Quote Link to comment https://forums.phpfreaks.com/topic/84499-remove-item-from-an-array/#findComment-430504 Share on other sites More sharing options...
gavin1512 Posted January 4, 2008 Author Share Posted January 4, 2008 still the same problem, it sending through the product number to the remove.php script but not removing it from the array Quote Link to comment https://forums.phpfreaks.com/topic/84499-remove-item-from-an-array/#findComment-430510 Share on other sites More sharing options...
duclet Posted January 4, 2008 Share Posted January 4, 2008 Comment out the header function for now so we can actually debug. Put an echo statement inside the if statement to see if it is actually reaching that. Also, try doing a print_r on the $_SESSION & $_GET['productnumber'] to make sure that you are actually getting the correct value. Quote Link to comment https://forums.phpfreaks.com/topic/84499-remove-item-from-an-array/#findComment-430550 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.