How to remove a variable from an array

From: Date: Sun, 02 Nov 2003 19:06:31 +0000
Subject: How to remove a variable from an array
Groups: php.general 
Request: Send a blank email to php-general+get-168346@lists.php.net to get a copy of this message
I have an array variable that is set, then put into a session variable. All is good so far, but how can I remove a specific variable from the array? I have tried basically copying and pasting this, and adding a foreach loop. Inside this foreach loop, the array is split apart and I tried using unnset, but I couldn't get it to work, so I deleted the code. Here is how I built the array: if ($_POST['4_Add'] != "") { if (($_POST['Frequent_Guest_Program'] != "") && ($_POST['Frequent_Guest_Number'] != "")) { $array = array(); $new = "{$_POST['Frequent_Guest_Program']},{$_POST['Frequent_Guest_Number']}" ; $old = $_SESSION['Frequent_Guest']; $array = array_merge($old, $new); $_SESSION['Frequent_Guest'] = $array; } header("Location: profile4.php"); } Thanks, Jake McHenry Nittany Travel MIS Coordinator http://www.nittanytravel.com

« previous php.general (#168346) next »