RE: [PHP] Dynamic Array Index using Variable
| From: | Jay Paulson \(CE CEN\) | Date: | Mon, 09 Jan 2006 21:01:19 +0000 |
| Subject: | RE: [PHP] Dynamic Array Index using Variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-228366@lists.php.net to get a copy of this message | ||
You could use the isset() or the empty() functions.
http://us3.php.net/manual/en/function.empty.php
http://us3.php.net/manual/en/function.isset.php
But do you want to check all the fields that are being submitted or just specific ones that you set
in the $reqfields array? If you want to check all the submitted fields just run through the $_POST
or $_GET arrays, depending on your form method.
jay
-----Original Message-----
From: Chris Lott [mailto:chris.lott@gmail.com]
Sent: Mon 1/9/2006 2:31 PM
To: PHP General Mailing List
Subject: [PHP] Dynamic Array Index using Variable
I want to do something like this to check if a variety of submitted
form fields (crn, instructor, etc) have any value in them:
$reqfields = array('crn', 'instructor');
$errorflag = 0;
foreach ($reqfields as $field) {
if ($_REQUEST[$field] == '') {
$errorflag = 1;
}
}
But I can't quite get the syntax right... help??
c
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php