gpt4 book ai didi

PHP:如何获取数组的最后一个值

转载 作者:行者123 更新时间:2023-12-05 08:24:15 27 4
gpt4 key购买 nike

我有以下 PHP 代码:

foreach ($resources as $resource)
{
// Iterates on the found IDs
//echo 'Name of field: ' . $resource . ' - Value: ' . $resource->attributes() . '<br />';
echo '<tr><td>'.$resource->attributes().'</td></tr>';
}

返回:

1
2
3
4
5
6
7
8

我只想获取最后一项的值:8我试过使用:

echo end(end($resources->attributes()));

但这会返回:1

关于如何获得 8 值的任何想法?

谢谢

最佳答案

end($resources)->attributes()

关于PHP:如何获取数组的最后一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16715045/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com