alhefner Posted October 19, 2006 Share Posted October 19, 2006 I am really new to php and need a little help exploring an array.I am running a script that uses the $_SESSION global as a multi-dimensional array. I don't know how many dimensions the array has.What I would like to do is loop through all of the array and echo the variable name, key names, and values.This will help me in my efforts to develope simple mods to my site without duplicating information or stepping on information already stored in the $_SESSION global.Thanks in advance!Al Quote Link to comment Share on other sites More sharing options...
craygo Posted October 19, 2006 Share Posted October 19, 2006 well to loop thru the array you can use a foreach statement.[code]<?phpforeach($_SESSION as $key => $val){ if(is_array($val)){ foreach($val as $key2 => $val2){ echo "$key: $key2 -- $val2<br>"; } } else { echo "$key: $val<br>"; }}?>[/code]Ray Quote Link to comment Share on other sites More sharing options...
alhefner Posted October 19, 2006 Author Share Posted October 19, 2006 The array check was missing from my first attempt. Thanks! I copied your code "as is" and am coming up with a blank page. I'll do some more exploration.Thanks again!Al Quote Link to comment Share on other sites More sharing options...
alhefner Posted October 19, 2006 Author Share Posted October 19, 2006 Don't I feel like a dummy! Forgot to "[b]start the session[/b]"!!No session = no session variables! 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.