PHP strstr()函数的用法是甚么
PHP strstr()函数用于在字符串中查找指定的子字符串,并返回从子字符串开始的剩余部份。它的语法以下:
strstr(string $haystack, mixed $needle, bool $before_needle = false): string|false
参数解释:
返回值:
示例:
$str = "Hello, World!";
$pos = strstr($str, "W");
echo $pos; // 输出:World!
在上面的示例中,我们在字符串"$str"中查找子字符串"W",并将结果赋值给变量"$pos"。然后,我们输出"$pos"的值,得到的结果是"World!",由于它是从子字符串"W"开始的剩余部份。
TOP