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 cameron7 on 11/11/07 15:03

This might work.

<?php
function myfunc($string,$pattern)
{
if(strpos(' '.$string.' ', ' '.$pattern.' ') !== FALSE)
{
return true;
}
return false;
}

var_dump(myfunc('Bob is from Los Angeles CA','CA'));
var_dump(myfunc('Bob is from Canada','CA'));
?>



On Nov 10, 4:09 pm, ross.one...@gmail.com wrote:
> Hi,
>
> 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
>
> Any help is appreciated
>
> Thanks
>
> -Ross

 

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

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