[thelist] PHP & arrays
Howard Cheng
howcheng at ix.netcom.com
Tue May 7 13:35:12 CDT 2002
First of all, the word 'or' isn't a keyword like in VBScript.
What you'll want is something more like:
if (!in_array("Jim",$myEmailP) || !in_array("John",$myEmailP || .. etc)
do_error();
Or better yet, create an array of the variables you want to check and loop
through it.
$checkArray = array("Jim","John","Frank","Bob");
foreach ($checkArray as $check)
{
if (!in_array($check,$myEmailP))
{
do_error();
break;
}
}
HTH.
At 10:27 AM 5/7/2002 -0700, Mark Joslyn wrote:
>I am trying to search through an array to determine if 4 distinct names
>appear in that array. If at least one of the names does not appear in the
>array, the error message gets called. But, if one of the names does appear,
>the error message is ignored. The in_array function works when there is one
>variable, but not multiple ones.
>
>Am I using the wrong function, or is my syntax messed up:
>
>
>if (!(in_array("Jim" or "John" or "Frank" or "Bob", $myEmailP)))
> error("Please enter a valid employee name.");
::::::::::::::::::::::
Howard Cheng
howcheng at ix.netcom.com
AIM: bennyphoebe
ICQ: 47319315
More information about the thelist
mailing list