Posted by Janwillem Borleffs on 10/25/05 15:26
Jorge A wrote:
> Is there any function in PHP to know if a string is a substring of
> another string?
>
> For instance:
> $title="White men can't jump";
> $text="white";
>
> function($title, $text) would return a boolean depending on $text is a
> substring or not.
>
> I have only found some string compare functions flicking through the
> documentation.
>
> Thanks in advance!
On PHP5:
$match = stripos($title, $text) !== false;
On PHP4:
$match = strpos(strtolower($title), strtolower($text)) !== false;
JW
[Back to original message]
|