php - Obtaining name of "father" array from "child" -


i want able name "father" array it's child, goal of writing http variables sent page, , written debug file. assuming have code (and page called remotely):

$father = array ( getallheaders(), $_post, $_get ); $info = ''; foreach ( $father $child ){   $info .= ${"child"} . "\n";   $info .= '--------------' . "\n";   foreach ( $child $key => $val ){     $info .= $key . ' : ' . $val . "\n";   }   $info .= "\n\n"; }  //write $info debug file 

what i'm hoping achieve debug file containing following information:

getallheaders() -------------- host : 1.2.3.4 connection : keep-alive // other members of getallheaders() array  $_post -------------- // assuming page called via http post input1 : input 1 text input2 : input 2 text // other members of $_post array  $_get -------------- // assuming page called via http input10 : input ten text input11 : input eleven text // other members of $_get array ... 

and on...

at moment, info in debug file want, "name" of father array i'm working on being displayed array : makes total sense, can't work out how it's name , display string value. contents of debug file:

array -------------- host : 1.2.3.4 connection : keep-alive // other members of getallheaders() array  array -------------- // assuming page called via http post input1 : input 1 text input2 : input 2 text // other members of $_post array  array -------------- // assuming page called via http input10 : input ten text input11 : input eleven text // other members of $_get array ... 

i know can create iterator within child's inner loop, , call $father[0], $father[1] , somehow convert name of array string, hoping direct me more "elegant" way of doing things?

your array not has information children. set appropriate keys:

$father = array ( 'getallheaders' => getallheaders(), '$_post' => $_post, '$_get' => $_get ); 

then change foreach in way:

foreach( $father $childname => $child ) {     $info .= "$childname\n";     (...) } 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -