$string = "01234567890*****12345678901234567890*"; echo strrpos($string,'*****');
为什么这会返回36而不是15? (click here测试)
07001
strrpos — Find the position of the last occurrence of a substring
in a string
我错过了什么?
谢谢!
解:
使用下面的答案,我提供了PHP4替代方案
$haystack = "01234567890*****12345678901234567890*"; $needle = '*****'; $position = strlen($haystack) - strlen($needle) - strpos(strrev($haystack),strrev($needle)); echo $position; // 11
可能你正在使用PHP 4:
from php.net
针:如果needle不是字符串,则将其转换为整数并应用为字符的序数值.针只能是PHP 4中的单个字符.