Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

php 去掉字符串的最后一个字符

 Share


HACK1949

Recommended Posts

在一个站长的空间看到这样的文章,觉得会有用,先记录下来

原字符串1,2,3,4,5,6,
去掉最后一个字符",",最终结果为1,2,3,4,5,6 

代码如下: 

  1. $str = "1,2,3,4,5,6,"; 
  2. $newstr = substr($str,0,strlen($str)-1); 
  3. echo $newstr; 
  4. //echo 1,2,3,4,5,6

系统自带的函数即可实现这样的效果,两种方法: 

  1. substr($str, 0, -1)
  2. //函数2
  3. rtrim($str, ",")
      https://www.cnblogs.com/yhyjy/archive/2012/02/22/2363008.html
Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...