获取数组的最后一个元素有很多方法,推荐使用php自带函数end()
end函数用法举例(来自w3c)
<?php $people = array("Peter", "Joe", "Glenn", "Cleveland"); echo current($people) . "<br />"; echo end($people); ?>
输出结果:
Peter
Cleveland
2021-09-23 04:21:44
获取数组的最后一个元素有很多方法,推荐使用php自带函数end()
end函数用法举例(来自w3c)
<?php $people = array("Peter", "Joe", "Glenn", "Cleveland"); echo current($people) . "<br />"; echo end($people); ?>
输出结果:
Peter
Cleveland