dongmi1995 2017-11-11 15:57
浏览 385
已采纳

如何在多个文本字符串中使用数组或in_array进行strpos

I made this code

$message = 'This domain has strpos';
$links = array('domain.com', 'do.main');
$safe = strpos($message, $links);
return $message;

but got error errorHandler->error in my page, whats wrong with my code? did I do some missing code?

what I want just detect if the message have string in $links then do rest of my code

thanks for droping out

  • 写回答

2条回答 默认 最新

  • dota220141003 2017-11-11 16:11
    关注

    Please try this one will give expected output.

    $message = 'This domain has strpos';
    $links = array('domain.com', 'do.main');
    $safe = array();
    foreach($links as $key=>$result){
        if(strpos($message, $result) != false){
          $safe[$result] = "String is available";   
        } else{
          $safe[$result] = "String is not available";       
        }
    
    }
    print_r($safe);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器