久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

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

      替換方法:1、使用str_replace()函數(shù)來(lái)替換,語(yǔ)法“str_replace(' ', "n", $str)”;2、使用str_ireplace()函數(shù)來(lái)替換,語(yǔ)法“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

      說(shuō)明:

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

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

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

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

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

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

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

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

      輸出:

      hello world !

      說(shuō)明:

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

      str_ireplace(find,replace,string,count)

      參數(shù)說(shuō)明:

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

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

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

      • count 可選。一個(gè)變量,對(duì)替換數(shù)進(jìn)行計(jì)數(shù)。

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

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