[nycphp-talk] Cycling through posted variables
Wellington Fan
beef at interport.net
Thu Jul 11 10:04:57 EDT 2002
Howdy,
This is quick-and-dirty code that I've used:
/*********************************************************/
foreach( $_POST as $k => $v ) {
if( is_array($v) ) {
echo '<hr>'.$k.' [Array]:<br>';
foreach($v as $t1 => $t2 ) {
echo sprintf("%40s : %s\
",'['.$t1.']',$t2);
}
} else {
echo sprintf("%20s : %s\
",$k,$v);
}
}
/*********************************************************/
It would be better & more elegant if it called a funtion that would recurse,
spitting out arrays of arrays of arrays .... etc.
Something like:
function printVals( thing )
global indent
if thing is scalar {
print indent thing
return
} else if thing is array {
print "ARRAY"
indent++
foreach( thing as subthing )
printVals( subthing )
indent--
}
return
}
--
Wellington
>> I'm trying to cycle through the "fields" posted through a form submit. I
More information about the talk
mailing list