RE: [PHP] Array form processing

From: Date: Wed, 30 Jun 2010 13:15:33 +0000
Subject: RE: [PHP] Array form processing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-306561@lists.php.net to get a copy of this message
> -----Original Message----- > From: Ron Piggott [mailto:ron.piggott@actsministries.org] > Sent: 29 June 2010 22:22 > > Am I on the right track? I don't know what to do with the second > "FOREACH" Sort of. > > <?php > > foreach($_REQUEST as $key => $val) { > $$key = $val; > echo $key . ": " . $val . "<br>"; > > if ( $val == "Array" ) { I would prefer to use is_array() here: if (is_array($val)) > $i=0; > At this point, you've just proved that $val is an array (whichever test you use!), so simply foreach it like one. I know you know how to do that as you did it with $_REQUEST above! > foreach ($val) { > echo "$val[$i]<br>"; > $i++; > } foreach ($val as $option) { echo "$option<br />\n"; } > > } > } > > ?> Cheers! Mike -- Mike Ford, Electronic Information Developer, Libraries and Learning Innovation, Leeds Metropolitan University, C507, Civic Quarter Campus, Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

« previous php.general (#306561) next »