Re: comparisons

From: Date: Fri, 22 Mar 2002 14:09:34 +0000
Subject: Re: comparisons
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-89685@lists.php.net to get a copy of this message
Hi Warwick I'd suggest looking at the PHP manual, it is available at http://www.php.net. You can look for string functions in the manual. If you were looking for a case insensitive comparision you could use stristr, if you are looking for a case senstivie comparision you could use strstr. <?php // code to see if john is in the variable $jeff = 'my name is john'; if (stristr($jeff, 'john')) { print 'john is in the variable'; } else { print 'john is not in the variable'; } ?> If you are trying to see if the variable is John then you could do this <? if ($jeff == 'John')) { print 'the variable is set to John'; } else { print 'the variable is not set to John'; } ?> There are other ways to do this, this is just an example I created. Jason ----- Original Message ----- From: "Warwick Berg" <support@thedantegroup.com> Newsgroups: php.general To: <php-general@lists.php.net> Sent: Friday, March 22, 2002 5:55 AM Subject: comparisons > Hi > > Just learning php from the bottom. Can someone help with syntax please? > > Want to know about using ifs : > > If the string value "john" is present in the variable "jeff" then do, etc, > etc. How do we see if a value is present in a string? > > Thanks > Warwick > > >

« previous php.general (#89685) next »