Array to Array pushing in Zend Session object
- by kate-koopy
Hello!  I have some example of pushing array to array in session object:
   class someClass extends someOtherOne {
...////// some other code here that starts session and  creates namespace
    public function __add2Session($a,$b) {  
    $namespc = $this -> __getnewNameSpace(); //returns a Zend Session Namesapce (object)
        if (!isset($namespc -> {$a})) { $namespc -> {$a} = array(); }
            array_push($namespc -> {$a}, $b);
        }
    }
.../////////////
$item=array(1=>"one",2=>"two",3=>"three",4=>"four",5=>"five",6=>"six",7=>"seven");
$k = new someClass();
$cart = new Zend_Session_Namespace('Cart');
$k -> __add2Session("items",$item);
The result is when I reload the page several times -  the value of $cart -> items in the session gets overwritten and not populated. Can somebody explain why it occurs and how do I fix this? 
I want to have $cart -> items to be an "array in array" like:
$cart -> items = array(array(1=>"one",2=>"two"), array(1=>"two",2=>"three"));