Delete first 3 characters and last 3 characters from String PHP

后端 未结 6 2045
情歌与酒
情歌与酒 2020-11-29 06:12

I need to delete the first 3 letters of a string and the last 3 letters of a string. I know I can use substr() to start at a certain character but if I need to strip both fi

6条回答
  •  情深已故
    2020-11-29 06:48

    Use

    substr($var,1,-1)
    

    this will always get first and last without having to use strlen.

    Example:

    
    

    Output:

    a,b,d,e,f

提交回复
热议问题