ListContains

The ListContains function is a quick and easy function to use. The ListContains function determines the index of the first list element that contains the specified substring. If the substring can not be found in the list, The ListContains function will returns zero. This function will not ignore empty sets; thus the list "a,b,c,,,d" has 8 elements
 
The Function:
<php
function ListContains($list,$substring,$delimiter=",")
{
    $delimiter = substr($delimiter,1);
    $a = explode($list,$delimiter);
    $return = 0;
    for($i=0;$i< count($a);$i++)
    {
        if(strstr($a[$i],$substring))
        {
            $return = $i + 1;
        }
    }
    return $return;
}

?>
Usage:
Using the ListContains function is simple:
 
<?php
    $list = "one,two,three";
    $substr = "two"
    if(ListContains($list,$substr) > 0)
    {
        echo $substr . " found at position " . ListContains($list,$substr):
    }
?>

The output of this function will be: two found at position 2