arrays - Echo only info - Session PHP -


how can echo information in session people added them self? script:

<?php session_start();  $array = $_session["wenslijst"];  if (isset($_post["item"]) && (int)$_post["item"] > 0)     {         if (!isset($_session["wenslijst"]))         {             $_session["wenslijst"] = array();             $_session["aantal"] = array();         }          $i = 0 ;         while ($i < count($_session["wenslijst"]) && $_session["wenslijst"][$i] != $_post["item"]) $i++;         if ($i < count($_session["wenslijst"]))         {             $_session["aantal"][$i]++;         }         else          {             $_session["wenslijst"][] = $_post["item"];             $_session["aantal"][] = 1;         } }  ?> 

when add product array looks this, echo bold message: (see long code spefic number product)

array ( [0] => array ( [f805862bbd430d0673f3f949249326f3] => ) )

thanks help.

aantal means: count

wenslijst means: wishlist

do understand correctly, array looks this?!

[0] => array(     "your_super_long_product_key" => array(),     "another_super_long_product_key" => array(),     "awesome_super_long_product_key" => array(), ) 

so access data this:

foreach(array_keys($array[0]) $key) {     echo $key . "\n"; } 

this give you:

your_super_long_product_key another_super_long_product_key awesome_super_long_product_key 

to loop through whole array use:

foreach($array $dataset) {     foreach(array_keys($dataset) $key) {         echo $key . "\n";     } } 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -