php去掉最后幾個字符的實現(xiàn)方法:首先創(chuàng)建一個PHP示例文件;然后定義一個字符串;最后通過“substr($str,0,-4);”方法去除最后的指定字符即可。
推薦:《PHP視頻教程》
<?php $str='programming'; //定義一個字符串 $res=substr($str,-4); //處理字符串 echo "返回{$str}字符串的最后4個字符{$res}"; $res=substr($str,0,-4); //處理字符串 echo "<br />返回{$str}字符串除去后4個字符{$res}";?>