gpt4 book ai didi

php - 检查多个 strpos 值

转载 作者:可可西里 更新时间:2023-11-01 13:03:13 25 4
gpt4 key购买 nike

我想知道如何完成多个 strpos 检查。

让我澄清一下:
我想让 strpos 检查变量“COLOR”,看看变量中是否有从 1 到 8 的任何数字。如果存在 1 到 8 之间的任何数字,我想回显“已选择”。

例子:
假设变量中只有数字 1,它回显“selected”。
假设数字 1 2 和 3 在变量中,它回显“selected”。
假设变量中有数字 3 9 25,它回显“selected”(因为那个 3!!)。
假设变量中只有数字 9,它不会回显。
假设数字 9 25 48 在变量中,它不会回显。

最佳答案

尝试多个preg匹配

if (preg_match('/word|word2/i', $str))

strpos() with multiple needles?

关于php - 检查多个 strpos 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19205726/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com