本文整理匯總了PHP中UTF8::wpstrtolower方法的典型用法代碼示例。如果您正苦於以下問題:PHP UTF8::wpstrtolower方法的具體用法?PHP UTF8::wpstrtolower怎麽用?PHP UTF8::wpstrtolower使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UTF8
的用法示例。
在下文中一共展示了UTF8::wpstrtolower方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wpstristr
/**
* Case-insensitive 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](http://php.net/stristr).
*
* $found = UTF8::stristr($str, $search);
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string $str input string
* @param string $search needle
* @return string matched substring if found
* @return FALSE if the substring was not found
*/
public static function wpstristr($str, $search)
{
if (UTF8::is_ascii($str) and UTF8::is_ascii($search)) {
return stristr($str, $search);
}
if ($search == '') {
return $str;
}
$str_lower = UTF8::wpstrtolower($str);
$search_lower = UTF8::wpstrtolower($search);
preg_match('/^(.*?)' . preg_quote($search_lower, '/') . '/s', $str_lower, $matches);
if (isset($matches[1])) {
return substr($str, strlen($matches[1]));
}
return FALSE;
}