我有一个字符串4345 5666 7768 6555
我想在获取最后四个字符之后首先删除它的空格,如何使用PHP?
答案 0 :(得分:1)
使用此代码
$str = "4345 5666 7768 6555";
$str = str_replace(" ","",$str);
echo $str = substr($str,-4);
答案 1 :(得分:0)
尝试 -
$str = str_replace(" ", "", $str); // replace spaces
echo substr($str, -4); // get last four characters
答案 2 :(得分:0)
$str = "4345 5666 7768 6555";
$str = str_replace(" ","",$str);
echo $str =trim(substr($str,-4));