doujiyong7604 2017-08-07 09:13
浏览 30
已采纳

在php中过滤数组中的特定列

I am trying to filter a specific column in an array in php using the code below:

(strpos( 'meeting',$event['categories'] ) == false )

It is not working actually. An example of what [categories] hold is:

$event['categories'] = 'meeting;skype'

Thanks in advance!

  • 写回答

3条回答 默认 最新

  • dongtao9887 2017-08-07 09:26
    关注

    You need to flip the arguments to strpos():

    if (strpos($event['categories'],  'meeting') === false) {
        echo $event['categories'] . ' does not contain "meeting"';
    }
    

    Also, use strict comparison (=== vs ==), as meeting could be at the start of the string, and then strpos() would return 0, which would evaluate to false (which would be wrong in that case).

    For reference, see:

    For an example, see:

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置