問題:我在使用雷劈網(wǎng)自定義表單,在提交到后端的富文本中,在富文本字符串中提取出了html標(biāo)簽的字符串,然后我想將富文本字符串中的html標(biāo)簽字符串替換為空格(也就是刪除~),于是我自信的使用 strripos(),結(jié)果得到的返回值是false 也就是,明明存在于字符串A中的字符串B,卻無法判斷他的出現(xiàn)位置,因此我無法達(dá)到替換B 的目的。
/* 保存數(shù)據(jù) */
foreach ($form as $v) {
$needle = $v["content"];
// var_dump($needle);
// $needle = '<input';
// echo '完整=>'.$contents.' <br> 標(biāo)簽=>'.$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;"/>"
提交的富文本:
PHP:strripos() 無法識(shí)別字符串類型的<input>標(biāo)簽?
慕田峪4524236
2019-03-17 04:09:19