Search for a string in another string

Submitted by:David Villa

Date added:19 September, 2011


If a string is contained in another string and you need to search for it, this is a very clever way to do it:

Tags: search string

Code Snippet:

function contains($str, $content, $ignorecase=true){
if ($ignorecase){
$str = strtolower($str);
$content = strtolower($content);
return strpos($content,$str) ? true : false;