久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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怎么將空格替換成換行符

      替換方法:1、使用str_replace()函數(shù)來替換,語法“str_replace(' ', "n", $str)”;2、使用str_ireplace()函數(shù)來替換,語法“str_ireplace(" ", "n", $str)”。

      php怎么將空格替換成換行符

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

      php將空格替換成換行符的方法:

      1、使用str_replace()函數(shù)

      <?php $str = 'a b c'; // 空格替換成換行符(n) $str = str_replace(' ', "n", $str); // 顯示字符 echo $str; ?>

      輸出:

      a b c

      說明:

      str_replace() 函數(shù)替換字符串中的一些字符(區(qū)分大小寫)。

      該函數(shù)必須遵循下列規(guī)則:

      • 如果搜索的字符串是一個數(shù)組,那么它將返回一個數(shù)組。

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

      • 如果同時需要對某個數(shù)組進行查找和替換,并且需要執(zhí)行替換的元素少于查找到的元素的數(shù)量,那么多余的元素將用空字符串進行替換。

      • 如果是對一個數(shù)組進行查找,但只對一個字符串進行替換,那么替代字符串將對所有查找到的值起作用。

      2、使用str_ireplace()函數(shù)

      <?php $str = 'hello world !'; $search = " "; $replace = "n"; echo str_ireplace($search, $replace, $str); ?>

      輸出:

      hello world !

      說明:

      str_ireplace() 函數(shù)替換字符串中的一些字符(不區(qū)分大小寫)。語法如下:

      str_ireplace(find,replace,string,count)

      參數(shù)說明:

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

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

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

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

      推薦學習:《PHP視頻教程》

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