Python有很大:如果子字符串中的字符串,像這樣:PHP版本,如果在
if "fox" in "The quick brown fox jumps over the lazy dog":
print True
確實做PHP有東西相當於這個?
Python有很大:如果子字符串中的字符串,像這樣:PHP版本,如果在
if "fox" in "The quick brown fox jumps over the lazy dog":
print True
確實做PHP有東西相當於這個?
有幾種方法。其一是:
if(stristr('fox','The quick brown fox jumps over the lazy dog') !== FALSE){
...code
}
http://php.net/manual/en/function.stristr.php
stripos函數和其他人可能更有效。見PHP String Functions
它的`===`|`!==`用於比較它的類型`==`|`!=`用於值比較,`=`用於指定 – RobertPitt 2010-12-02 21:41:06
有三個,我能想到的:substr,strpos和strstr。其中的每一個都區分大小寫,並且這些功能也有不區分大小寫的版本。 PHP有一些荒謬的字符串處理命令,所以你只需仔細閱讀string section of the manual,直到看到你想要的。
感謝關於嚴格比較的註釋 – imns 2010-12-02 21:31:06