You are here: Re: Is there any function in php that will match a word exactly and if it finds it, it returns true. « PHP Programming Language « IT news, forums, messages
Re: Is there any function in php that will match a word exactly and if it finds it, it returns true.

Posted by mik3l3374 on 11/11/07 01:43

On Nov 11, 5:37 am, Krustov <m...@privacy.net> wrote:
> <comp.lang.php>
> <>
> <Sat, 10 Nov 2007 13:09:14 -0800>
> <1194728954.083106.150...@c30g2000hsa.googlegroups.com>
>
> > Is there any function in php that will match a word exactly and if it
> > finds it, it returns true.
>
> > For example if I search for "CA"
>
> > strVar = "Bob is from Los Angeles CA" - return true
>
> > strVar "Bob is from Canada" -- returns false
>
> $demo="Bob is from Los Angeles CA";
>
> $qaz="CA";
>
> $wsx=strpos($qaz,$demo);
>
> if ($wsx==true) {print "exact match found";}
>
> NOTE: untested and you may need to play around with it .
using strpos, this would also match

$demo="Bob is from Los Angeles CAblahblah";

while i think OP wanted exact match. Correct me if i am wrong.

maybe something like this:

$demo="Bob is from Los Angeles CA ddfs";
$s = split(" ",$demo);
foreach ($s as $k)
{
if( $k === "CA" )
{
echo "Found CA: $k\n";
}
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация