is there a quicker way to do this?
Posted: Wed Mar 03, 2010 2:13 pm
Hello. i am making an itinerary option for my uni project
i have the following code to remove an element from the session's intin array.
because i need the session array's key to stay as 1,2,3,4 when an item is removed not 1,2,4 i have found that i had to save the array into a new array, clear the session[intin] then reassign it.
is there a better and faster way?!!? please help
$pointer=$_GET["q"];
unset($_SESSION['intin'][$pointer]);
$object=(array_values($_SESSION['intin']));
$_SESSION[intin]=array();
foreach($object as $key)
{
$_SESSION[intin]=$object;
}
i have the following code to remove an element from the session's intin array.
because i need the session array's key to stay as 1,2,3,4 when an item is removed not 1,2,4 i have found that i had to save the array into a new array, clear the session[intin] then reassign it.
is there a better and faster way?!!? please help
$pointer=$_GET["q"];
unset($_SESSION['intin'][$pointer]);
$object=(array_values($_SESSION['intin']));
$_SESSION[intin]=array();
foreach($object as $key)
{
$_SESSION[intin]=$object;
}