Solarpitch Posted November 16, 2007 Share Posted November 16, 2007 Hey, Heads melted working with arrays all day! I have this piece of code below that will store the user's favorites items on the site. It basically adds the item id to the session array. I just want to know how I can then list all the item id's from that session array to store in a variable? cheers if(isset($_GET['fav'])) { $_SESSION['favs'][] = $property_id; foreach($_SESSION['favs'] as $key=>$val) { } } // Here's how I can list them and print them to screen, but this is no good as each item id in the session array will need to be put into an sql query. So I need to individually pick each id out of the array. while (list(,$v) = each ($favs)) { echo $v } Quote Link to comment Share on other sites More sharing options...
teng84 Posted November 16, 2007 Share Posted November 16, 2007 <? $_SESSION['favs'][] ='teng1'; $_SESSION['favs'][] ='teng2'; $_SESSION['favs'][] ='teng3'; $_SESSION['favs'][] ='teng4'; $_SESSION['favs'][] ='teng5'; foreach($_SESSION['favs'] as $key=>$val){ echo "$"."_SESSION"."[favs][".$key ."]=".$val; echo '<br>'; } ?> see this sample Quote Link to comment Share on other sites More sharing options...
Solarpitch Posted November 16, 2007 Author Share Posted November 16, 2007 Absolutely perfect! Now I can sleep early! Thanks man Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.