开发者

Trim string from left and from right

开发者 https://www.devze.com 2023-03-03 11:49 出处:网络
How can I trim 5 characters from a string from left and right side. e.g. 4k2l3k4jc9l3kancie9 What should be trimmed and kept are:

How can I trim 5 characters from a string from left and right side. e.g.

4k2l3k4jc9l3kancie9

What should be trimmed and kept are:

4k2l3      k4jc9l3ka     ncie9
  ^            ^           ^
remove        keep      开发者_如何转开发 remove


$string = substr($string, 5, -5);


$string = substr($string, 5, -5);//from left
$string = substr($string, 0, 5);//from right
0

精彩评论

暂无评论...
验证码 换一张
取 消