如何使用 php 搜索文本 if ($text contains “World") [英] How to search text using php if ($text contains "World")
本文介绍了如何使用 php 搜索文本 if ($text contains “World")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用php搜索文本?
How to search text using php?
类似于:
<?php
$text = "Hello World!";
if ($text contains "World") {
echo "True";
}
?>
除了用工作条件替换 if ($text contains "World") {
.
Except replacing if ($text contains "World") {
with a working condition.
推荐答案
在你的情况下,你可以使用 strpos()
或 stripos()
用于不区分大小写的搜索:
In your case you can just use strpos()
, or stripos()
for case insensitive search:
if (stripos($text, "world") !== false) {
echo "True";
}
这篇关于如何使用 php 搜索文本 if ($text contains “World")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文