问题:我在使用雷劈网自定义表单,在提交到后端的富文本中,在富文本字符串中提取出了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
<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;"/>"
提交的富文本:
添加回答
举报
0/150
提交
取消