How to remove the last few characters in php: first create a PHP sample file; then define a string; finally remove the last specified characters through the "substr($str,0,-4);" method That’s it.
Recommended: "PHP Video Tutorial"
<?php $str='programming'; //定义一个字符串 $res=substr($str,-4); //处理字符串 echo "返回{$str}字符串的最后4个字符{$res}"; $res=substr($str,0,-4); //处理字符串 echo "<br />返回{$str}字符串除去后4个字符{$res}";?>
The above is the detailed content of How to remove the last few characters in php. For more information, please follow other related articles on the PHP Chinese website!