我有以下 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/