选择语言 :

 Core_UTF8::stristr

Case-insenstive UTF-8 version of strstr. Returns all of input string from the first occurrence of needle to the end. This is a UTF8-aware version of stristr.

$found = UTF8::stristr($str, $search);

string Core_UTF8::stristr( string $str , string $search )
author
Harry Fuecks hfuecks@gmail.com

参数列表

参数 类型 描述 默认值
$str string Input string
$search string Needle
返回值
  • string matched substring if found
  • FALSE if the substring was not found
File: ./core/classes/utf8.class.php
public static function stristr($str, $search)
{
    if ( UTF8::is_ascii($str) and UTF8::is_ascii($search) ) return stristr($str, $search);

    if ( $search == '' ) return $str;

    $str_lower = UTF8::strtolower($str);
    $search_lower = UTF8::strtolower($search);

    preg_match('/^(.*?)' . preg_quote($search_lower, '/') . '/s', $str_lower, $matches);

    if ( isset($matches[1]) ) return substr($str, strlen($matches[1]));

    return FALSE;
}