[PHP] Re: unless something...

2002-09-12 Thread Neophyte

if ($A != $C || $B != $C) {

I think, but im fairly new


Magnus Solvang [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm used to the unless-statement in perl... How do I do this:

   if string A or B are NOT in string C, then do something and quit.

 In perl, I would do this:

 unless ($c =~ /$a|$b/) {
   blabla
   exit 0
 }

 - M



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




RE: [PHP] Re: unless something...

2002-09-12 Thread Johnson, Kirk

There is no 'unless' in PHP, so you just have to grind it out. If you are
searching for known strings, rather than string *patterns*, use the strstr()
function here: http://www.php.net/manual/en/function.strstr.php.

So, something like:

if(!strstr($c,$a)  !strstr($c,$b)) {
  bla;
  exit;
}

Completely untested ;) If you are looking for patterns, see preg_match(),
linked to from the link above.

Kirk

 Magnus Solvang [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I'm used to the unless-statement in perl... How do I do this:
 
if string A or B are NOT in string C, then do something and quit.
 
  In perl, I would do this:
 
  unless ($c =~ /$a|$b/) {
blabla
exit 0
  }

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




RE: [PHP] Re: unless something...

2002-09-12 Thread David Buerer

True, but isn't unless just a negated while?


q.e.d.

while ($c==$a OR $c==$b) 
{
  blabla
  exit 0
}


-Original Message-
From: Johnson, Kirk [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 12, 2002 10:28 AM
To: [EMAIL PROTECTED]
Subject: RE: [PHP] Re: unless something...


There is no 'unless' in PHP, so you just have to grind it out. If you are
searching for known strings, rather than string *patterns*, use the strstr()
function here: http://www.php.net/manual/en/function.strstr.php.

So, something like:

if(!strstr($c,$a)  !strstr($c,$b)) {
  bla;
  exit;
}

Completely untested ;) If you are looking for patterns, see preg_match(),
linked to from the link above.

Kirk

 Magnus Solvang [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  I'm used to the unless-statement in perl... How do I do this:
 
if string A or B are NOT in string C, then do something and quit.
 
  In perl, I would do this:
 
  unless ($c =~ /$a|$b/) {
blabla
exit 0
  }

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




RE: [PHP] Re: unless something...

2002-09-12 Thread Johnson, Kirk

Indeed, it is a negated something or other.

 -Original Message-
 From: David Buerer [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, September 12, 2002 11:23 AM
 To: '[EMAIL PROTECTED]'
 Subject: RE: [PHP] Re: unless something...
 
 
 True, but isn't unless just a negated while?

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




RE: [PHP] Re: unless something...

2002-09-12 Thread David Freeman

Doing stuff with || is always a good way to stuff up.  In the case of
your example it will always evaluate to true.

  if ($A != $C || $B != $C) {
  
  I think, but im fairly new

This would work if you did this:

If (!($A == $C || $B == $C)) {

   In perl, I would do this:
  
   unless ($c =~ /$a|$b/) {
 blabla
 exit 0
   }




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