public function indexOf($string, $search, $fromIndex = null)
    {
        $string = (string)$string;

        $fromIndex = max(0, $fromIndex);
        if ($search === '') {
            return min(mb_strlen($string, 'UTF-8'), $fromIndex);
        }
        $index = mb_strpos($string, $search, $fromIndex, 'UTF-8');
        if ($index === false) {
            return -1;
        }
        return (integer)$index;
    }
public function indexOf($string, $search, $fromIndex = null)
    {
        $string = (string)$string;

        $fromIndex = max(0, $fromIndex);
        if ($search === '') {
            return min(mb_strlen($string, 'UTF-8'), $fromIndex);
        }
        $index = mb_strpos($string, $search, $fromIndex, 'UTF-8');
        if ($index === false) {
            return -1;
        }
        return (integer)$index;
    }
public function indexOf ( $ string , $ search , $ fromIndex = null ) { $ string = ( string ) $ string ; $ fromIndex = max ( 0 , $ fromIndex ) ; if ( $ search === '' ) { return min ( mb_strlen ( $ string , 'UTF-8' ) , $ fromIndex ) ; } $ index = mb_strpos ( $ string , $ search , $ fromIndex , 'UTF-8' ) ; if ( $ index === false ) { return - 1 ; } return ( integer ) $ index ; }
Find the first position of a substring in the given string

Example::

String.indexOf("Blue Whale", "Blue") == 0

@param string $string The input string
@param string $search The substring to search for
@param integer $fromIndex The index where the search should start, defaults to the beginning
@return integer The index of the substring (>= 0) or -1 if the substring was not found
Find the first position of a substring in the given string