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

posted @ 2020-07-04 14:30  小猿笔记  阅读(1634)  评论(0编辑  收藏  举报