【问题标题】:Problem with the returning value from striposstripos 返回值的问题
【发布时间】:2022-12-18 02:46:40
【问题描述】:

假设 $arr1 是一个数组,$haystack 是一个字符串,当我在我的类中调用这个方法时,它没有正确响应。

$arr1 = ['Aris', 'boris', 'Cinos'];
$haystack = 'Aristotele';    

for ($i = 0; $i < count($arr1); $i++) {
    if (stripos($haystack, $arr1[$i]) !== false) {
        echo true;
    }
    echo false;
}

它结束时什么都不回显,也不假。

【问题讨论】:

    标签: php arrays substring stripos


    【解决方案1】:

    你的论点在 stripos 中被颠倒了。 $haystack 应该排在第一位。回显 true 将返回 1,false 将不返回任何内容,这就是您什么都看不到的原因。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-04
      • 1970-01-01
      相关资源
      最近更新 更多