Re: variable ?
| From: | Philip Olson | Date: | Mon, 18 Dec 2000 19:36:21 +0000 |
| Subject: | Re: variable ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30894@lists.php.net to get a copy of this message | ||
Try this , assuming you're using POST (you can change to GET) :
foreach ($HTTP_POST_VARS as $name => $value) {
if (!empty($value)) {
$full_vars[$name] = $value;
} else {
$empty_vars[$name] = $values;
}
}
Which creates two arrays, to print them out you could do let's say :
foreach ($full_vars as $name => $value) {
print "<br>$name is $value";
}
foreach ($empty_vars as $name => $value) {
print "<br>$name is empty";
}
Regards,
Philip
--.sig
[ Want to write Good code? First, write Bad code. ]
On Mon, 18 Dec 2000, JB wrote:
> Ok.. i am assuming you have a form with 8 fields.. right?
> and 4 of them can be left blank.
> and you want to see which 4 WERE FILLED OUT?
> do this:
> if($var1!="") {
> $var1_status = 1; /// 1 for being filled out
> ///optionally you can do something else besides
> /// assigning status of course
> }
> else {
> $var1_status = 0; ///0 for being not filled out
> }
>
>
>
> repeat this for each variable name. of course you can perform any action
> instead of assigning a "status variable" for each one.
>
>
> Mike <mpeloso@princeton.edu> wrote in message
> news:91lkm2$lf1$1@toye.p.sourceforge.net...
> > I have a form that passes 4 of a possible 8 variables to a script.How can
> I
> > tell which 4 were passed?
> > Mike P
> > mpeloso@princeton.edu
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> > For additional commands, e-mail: php-general-help@lists.php.net
> > To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >
> >
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>