函数名:iconv_strpos()
适用版本:PHP 4 >= 4.0.5, PHP 5, PHP 7
用法:iconv_strpos(string $haystack, string $needle, int $offset = 0, string $charset = ini_get("iconv.internal_encoding")): int|false
说明:iconv_strpos() 函数用于在一个字符串中查找另一个字符串的首次出现位置。与 strpos() 函数不同的是,iconv_strpos() 函数可以处理多字节字符集。
参数:
返回值:
示例:
$haystack = "Hello, 你好!";
$needle = "你好";
$position = iconv_strpos($haystack, $needle);
if ($position !== false) {
echo "找到了 '$needle',位置在 $position";
} else {
echo "未找到 '$needle'";
}
输出:
找到了 '你好',位置在 7
注意事项: