为了账号安全,请及时绑定邮箱和手机立即绑定

PHP:strripos() 无法识别字符串类型的<input>标签?

PHP:strripos() 无法识别字符串类型的<input>标签?

PHP
慕田峪4524236 2019-03-17 04:09:19
问题:我在使用雷劈网自定义表单,在提交到后端的富文本中,在富文本字符串中提取出了html标签的字符串,然后我想将富文本字符串中的html标签字符串替换为空格(也就是删除~),于是我自信的使用 strripos(),结果得到的返回值是false 也就是,明明存在于字符串A中的字符串B,却无法判断他的出现位置,因此我无法达到替换B 的目的。 /* 保存数据 */ foreach ($form as $v) { $needle = $v["content"]; // var_dump($needle); // $needle = '<input'; // echo '完整=>'.$contents.' <br> 标签=>'.$needle; var_dump($contents); var_dump($needle); $start = stripos($contents, $needle);//TODO 为啥是空白? if ($start!=false) { $length = strlen($needle); echo '操作前' . $contents . '--------------$start=' . $start . ',$length=' . $length . '<br>'; $contents = $this->str_replace_once($needle, '', $contents);// 替换表单在html中的占位 // $contents = substr_replace($contents, "", $start, $length); // echo '操作后=' . $contents . '<br>'; } } 上边代码:从contents中 替换needle 为空白字符串 。 var_dump($contents);==> string(204) "<p>asdfasdf&nbsp; <input name="leipiNewField" type="text" title="fdasfd" value="" leipiplugins="text" orghide="0" orgalign="left" orgwidth="150" orgtype="text" style="text-align: left; width: 150px;"/></p>" var_dump($needle);==>string(184) " <input name="leipiNewField1" type="text" title="fdasfd" value="" leipiplugins="text" orghide="0" orgalign="left" orgwidth="150" orgtype="text" style="text-align: left; width: 150px;"/>" 提交的富文本:
查看完整描述

1 回答

?
萧十郎

TA贡献1815条经验 获得超13个赞

因为没匹配到啊

查看完整回答
反对 回复 2019-03-18
  • 1 回答
  • 0 关注
  • 460 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信