Jump to content

Help exploring an "unknown" array *solved*


alhefner

Recommended Posts

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
Link to comment
Share on other sites

well to loop thru the array you can use a foreach statement.

[code]<?php
foreach($_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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.