久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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如何去掉字符串末尾字符

      php去掉字符串末尾字符的方法:1、直接使用substr()函數(shù)倒序裁掉最后一位字符,語法“substr(string,0,-1)”;2、使用rtrim()函數(shù),語法“rtrim(string,charlist)”。

      php如何去掉字符串末尾字符

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

      php去掉字符串末尾字符

      方法1:使用substr()函數(shù)

      直接使用substr()函數(shù)倒序裁掉最后一位字符

      <?php header('content-type:text/html;charset=utf-8'); $str = '123,234,345,'; echo "原字符串:",$str,'<br/>'; echo "去掉末尾字符的字符串:",substr($str,0,-1); ?>

      輸出:

      原字符串:123,234,345, 去掉末尾字符的字符串:123,234,345

      說明:

      substr() 函數(shù)返回字符串的一部分。語法:

      substr(string,start,length)

      php如何去掉字符串末尾字符

      方法2:使用rtrim()函數(shù)

      rtrim() 函數(shù)移除字符串右側(cè)的空白字符或其他預(yù)定義字符。

      1、指定末尾字符

      <?php header('content-type:text/html;charset=utf-8'); $str = '123,234,345,'; echo "原字符串:",$str,'<br/>'; echo "去掉末尾字符的字符串:",rtrim($str,','); ?>

      輸出:

      原字符串:123,234,345, 去掉末尾字符的字符串:123,234,345

      2、不知道末尾字符

      <?php header('content-type:text/html;charset=utf-8'); $str = '123,234,345,1'; echo "原字符串:",$str,'<br/>';  //不知道末尾字符,需先獲取末字符 $last_char=$str{strlen($str)-1};  echo "去掉末尾字符的字符串:",rtrim($str,$last_char); ?>

      輸出:

      原字符串:123,234,345,1 去掉末尾字符的字符串:123,234,345,

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

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