RE: Array form processing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Ron Piggott [mailto:ron.piggott@xxxxxxxxxxxxxxxxxx]
> 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@xxxxxxxxxxxxxx 
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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux