php 截取取最后一个字符【转】

方法一:

$str = " www.wdphp.com ";
$var = trim($str);
$len = strlen($var)-1;
echo $var[$len];

方法二:

$str = "www.wdphp.com";
echo substr($str, -1);

来源:https://blog.csdn.net/yvsm316/article/details/77049671

相关推荐