欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          php如何替換數(shù)組里的字符串

          php替換數(shù)組里的字符串的方法:可以利用str_replace函數(shù)來進行替換,如【str_replace("red","pink",$arr,$i)】。如果搜索的字符串是一個數(shù)組,那么它將對數(shù)組中的每個元素進行查找和替換。

          php如何替換數(shù)組里的字符串

          本文操作環(huán)境:windows10系統(tǒng)、php 7.3、thinkpad t480電腦。

          如果我們需要替換數(shù)組中的字符串,可以利用str_replace()函數(shù)。

          提示:如果搜索的字符串是一個數(shù)組,那么它將對數(shù)組中的每個元素進行查找和替換。

          語法:

          str_replace(find,replace,string,count)

          參數(shù)介紹:

          • find 必需。規(guī)定要查找的值。

          • replace 必需。規(guī)定替換 find 中的值的值。

          • string 必需。規(guī)定被搜索的字符串。

          • count 可選。一個變量,對替換數(shù)進行計數(shù)。

          代碼示例:

          <!DOCTYPE html> <html> <body>  <?php $arr = array("blue","red","green","yellow"); print_r(str_replace("red","pink",$arr,$i)); echo "<br>" . "Replacements: $i"; ?>  <p>In this example, we search an array to find the value "red", and then we replace the value "red" with "pink".</p>  </body> </html>

          (學習視頻分享:php視頻教程)

          運行結果:

          php如何替換數(shù)組里的字符串

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