久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      php怎么去掉數(shù)組元素中的html標簽

      實現(xiàn)步驟:1、使用foreach語句通過引用循環(huán)的方式遍歷數(shù)組元素,語法“foreach ($array as &$value) { //循環(huán)體代碼}”;2、在循環(huán)體中,使用strip_tags()函數(shù)去掉數(shù)組元素中的html標簽即可,語法“$value=strip_tags($value);”。

      php怎么去掉數(shù)組元素中的html標簽

      本教程操作環(huán)境:windows7系統(tǒng)、PHP8版、DELL G3電腦

      php去掉數(shù)組元素中html標簽的方法

      在php中,可以利用foreach語句和strip_tags()函數(shù)來去掉數(shù)組元素中的html標簽。

      實現(xiàn)步驟:1、使用foreach語句通過引用循環(huán)的方式遍歷數(shù)組元素

      一般情況下,使用foreach語句遍歷數(shù)組時,是對數(shù)組的備份進行操作,一般不會影響數(shù)組本身。

      而想要影響數(shù)組本身,修改數(shù)組元素就需要采用引用循環(huán)(在 $value 之前加上 &),這樣foreach語句會以引用賦值而不是拷貝一個值。

      foreach ($array as &$value) {      //循環(huán)體代碼 }
      登錄后復(fù)制

      步驟2:在循環(huán)體中,使用strip_tags()函數(shù)去掉數(shù)組元素中的html標簽

      $value=strip_tags($value);
      登錄后復(fù)制

      這樣循環(huán)結(jié)束,數(shù)組中的html標簽就會全部去除。

      實現(xiàn)示例:

      <?php $array= array("1<br>","hello<br>","This is some <b>bold<b> text.","<b>4<b>","<s>5<s>"); var_dump($array); foreach ($array as &$value) {      $value=strip_tags($value); } var_dump($array); ?>
      登錄后復(fù)制

      php怎么去掉數(shù)組元素中的html標簽

      擴展知識:strip_tags() 函數(shù)

      strip_tags() 函數(shù)剝?nèi)プ址械?HTML、XML 以及 PHP 的標簽。

      注釋:該函數(shù)始終會剝離 HTML 注釋。這點無法通過 allow 參數(shù)改變。

      注釋:該函數(shù)是二進制安全的。

      strip_tags(string,allow)
      登錄后復(fù)制

      參數(shù) 描述
      string 必需。規(guī)定要檢查的字符串。
      allow 可選。規(guī)定允許的標簽。這些標簽不會被刪除。

      返回值:返回被剝離的字符串。

      示例1:剝?nèi)プ址械娜?HTML 標簽:

      <?php $str="<s>Hello</s><br> <b>world!</b>"; echo strip_tags($str); ?>
      登錄后復(fù)制

      php怎么去掉數(shù)組元素中的html標簽

      示例2:剝?nèi)プ址械?HTML 標簽,但允許使用 <b> 標簽:

      <?php echo strip_tags("Hello <b><i>world!</i></b>","<b>"); ?>
      登錄后復(fù)制

      php怎么去掉數(shù)組元素中的html標簽

      推薦學(xué)習(xí):《PHP視頻教程》

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號