Jump to content

[SOLVED] Array Question


php-pendejo

Recommended Posts

Ok im using this code to debug and get all the globals that are posted on my site

$ArrayList = array("_POST", "_GET", "_COOKIE", "_ENV", "_FILES", "_SESSION", "_SERVER");
foreach($ArrayList as $gblArray) {
  $keys = array_keys($$gblArray);
  $DebugInfo .=  "\n Key: $gblArray - \n";
  foreach($keys as $key){
    @$$key = trim(${$gblArray}[$key]);
    if (is_array($$key)){
      for($i=0; sizeof($$key); $i++){
        $DebugInfo .=  "$key = ". @$$key[$i] . " \n";
      }
    } else {
      $DebugInfo .=  "$key = ". @$$key . " \n";
    }
  }
}

heres the delema. what i need is if $$key is an array to spit it out instead of saying its an array

 

can anyone help?

 

the way I am posting is

<select name="block[]" multiple>
<option value = 1> test1</option>
<option value = 2> test2</option>
<select>

or something like that 

Link to comment
https://forums.phpfreaks.com/topic/132453-solved-array-question/
Share on other sites

If you're just wanting a dump of info for debug purposes, just do something like

 

<?php
$ArrayList = array("_POST", "_GET", "_COOKIE", "_ENV", "_FILES", "_SESSION", "_SERVER");
foreach($ArrayList as $gblArray) {
   echo "$gblArray<br/>";
   echo "<pre>";
   print_r($$gblArray);
   echo "</pre>";
}
?>

okay well first off, you say in the OP you're trying to spit out info, not put it into an array.  You just explained how you were having issues trying to spit out info from an array.  To me, that means you're trying to spit out info, not put info into an array. 

 

2nd, it's print_r, not print_f.

ok i want to apologize for saying what i said. I figued out... sorry I didn't see your second post when i replied.

 

once i saw that i did this

 

$Debug_Info = htmlspecialchars(print_r(get_defined_vars(), true));

 

it made life easier so thank you very much :P lol

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.