drcmg28484 2012-04-24 18:59
浏览 10

PHP:如何弹出数组中的最后一项而不实际从数组中删除它? [重复]

Possible Duplicate:
PHP get index of last inserted item in array

I have an array or variable length and would like a quick and easy way to know the value of the last item in the array (without actually removing it from the array). How can I pop the last item off the array without actually removing it from the array?

  • 写回答

4条回答 默认 最新

  • dongmaopiao0901 2012-04-24 19:01
    关注

    $lastitem = $array[count($array)-1]

    this is an alternative to using end, so that you don't have the consequence of having the array's internal pointer moved to the end of the array end - php.net

    评论

报告相同问题?

悬赏问题

  • ¥15 求指导ADS低噪放设计
  • ¥15 CARSIM前车变道设置
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存