rag*_*ghu 5 php string function
当我搜索"银行"时,它应显示以下列表中的Bank-List1,Bank-List2.
铁路列表,银行列表1,银行列表2,教育,电子商务,文章,铁路列表1.
是否有任何PHP功能可以显示?
我得到了完全匹配的输出.但这种搜索没有结果.
请帮我找到解决方案.
你可以使用stristr
\n\nstristr \xe2\x80\x94 Case-insensitive strstr()
<?php // Example from PHP.net\n $string = \'Hello World!\';\n if(stristr($string, \'earth\') === FALSE) {\n echo \'"earth" not found in string\';\n }\n// outputs: "earth" not found in string\n?> \n
Run Code Online (Sandbox Code Playgroud)\n\n因此,对于您的情况,如果您的列表位于名为的数组中$values
你可以做
\n\nforeach($values as $value)\n{\n if(stristr($value, \'bank\') !== FALSE) \n {\n echo $value."<br>";\n }\n}\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
7546 次 |
最近记录: |