开发者社区 问答 正文

在strpos中使用数组作为指针

strpos搜索字符串时,如何使用针阵列?例如:

$find_letters = array('a', 'c', 'd'); $string = 'abcdefg';

if(strpos($string, $find_letters) !== false) { echo 'All the letters are found in the string!'; } 因为当使用它时,它不起作用,如果有这样的东西,那会很好 问题来源于stack overflow

展开
收起
保持可爱mmm 2020-02-08 14:09:31 480 分享 版权
1 条回答
写回答
取消 提交回答
  • str_replace相当快。

    $find_letters = array('a', 'c', 'd'); $string = 'abcdefg'; $match = (str_replace($find_letters, '', $string) != $string);

    2020-02-08 14:09:40
    赞同 展开评论
问答标签:
问答地址: