如何使用 php 搜索文本?
类似:
<?php
$text = "Hello World!";
if ($text contains "World") {
echo "True";
}
?>
除了将 if ($text contains "World") {
替换为工作条件。
最佳答案
在您的情况下,您可以只使用 strpos()
, 或 stripos()
对于不区分大小写的搜索:
if (stripos($text, "world") !== false) {
echo "True";
}
关于php - 如何使用 php 搜索文本 if ($text contains "World"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3950622/