[thelist] PHP & arrays

Magnus Østergaard magnus at slackware.adsl.dk
Tue May 7 14:13:00 CDT 2002


Howard Cheng wrote:
>
> First of all, the word 'or' isn't a keyword like in VBScript.

'or' is a keyword, se:
http://www.php.net/manual/en/language.operators.php

However I agree that '||' looks nicer.

> 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;
>      }
> }

> At 10:27 AM 5/7/2002 -0700, Mark Joslyn wrote:
> >
> >if (!(in_array("Jim" or "John" or "Frank" or "Bob", $myEmailP)))
> >                 error("Please enter a valid employee name.");

--
Magnus Østergaard

Sometimes the light at the end of the tunnel is an oncoming train.



More information about the thelist mailing list