php session array


i need to know how to:-

  1. set up a session array
  2. add items to the array
  3. remove items from array
  4. list items in array


the first thing you need to do to set up sessions you need to start the sessions.

then you cand declare it.

[php]$my_array = array(‘red’, ‘blue’, ‘black’, ‘white’);
$_SESSION[‘colors’] = $my_array;[/php]

To output the sessions array you will need a foreach loop.

[php]foreach($_SESSION[‘colors’] as $key=>$value)
echo ‘Value of $_SESSION[’."’".$key."’".’] is ‘."’".$value."’".’’;

To unset the items from array you will need unset();

you will get the id from the output or you can declare it in the array.

[php]array(‘id1’ => ‘white’, ‘id2’=>‘black’);[/php]and so on…