Rated an average of 5 stars by 1 person

Search for a String in Another String

Script Details:
Added on December 19, 2010 by Zhay.
Zhay accreditted the script to "http://www.jonasjohn.de/snippets/php/contains.htm."

Description:
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: contains, search, string

Code:

<?php
# Snippet from PHP Share: http://www.phpshare.org

function contains($str$content$ignorecase true)
{
    if (
$ignorecase)
    {
        
$str strtolower($str);
        
$content strtolower($content);
    }
    
    return 
strpos ($content$str) ? truefalse;
}
?>

Review this PHP Script:

Rating:

Comments:


Login

User:
Pass:

Register

Not a member? Register today and receive the many free benefits of being a member!

Advertisements