鍍金池/ 問(wèn)答/PHP  Linux  數(shù)據(jù)庫(kù)  HTML/ PHP:strripos() 無(wú)法識(shí)別字符串類型的<input>標(biāo)簽

PHP:strripos() 無(wú)法識(shí)別字符串類型的<input>標(biāo)簽?

問(wèn)題:
我在使用雷劈網(wǎng)自定義表單,在提交到后端的富文本中,在富文本字符串中提取出了html標(biāo)簽的字符串,然后我想將富文本字符串中的html標(biāo)簽字符串替換為空格(也就是刪除~),于是我自信的使用 strripos(),結(jié)果得到的返回值是false 也就是,明明存在于字符串A中的字符串B,卻無(wú)法判斷他的出現(xiàn)位置,因此我無(wú)法達(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&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;"/>"

提交的富文本:
圖片描述

回答
編輯回答
紓惘

因?yàn)闆](méi)匹配到啊

2017年6月18日 04:15