Php Mootools从每个工具中获取第一个值

Php Mootools从每个工具中获取第一个值,php,ajax,json,mootools,Php,Ajax,Json,Mootools,我有一个来自Json的数组图像: images=JSON.decode(images); 这是数组值: [ { "title": "", "description": "", "name": "loc commerciale.jpg" }, { "title": "", "description": "", "name": "foto2.jpg" }, {

我有一个来自Json的数组图像:

images=JSON.decode(images);
这是数组值:

[
    {
        "title": "",
        "description": "",
        "name": "loc commerciale.jpg"
    },
    {
        "title": "",
        "description": "",
        "name": "foto2.jpg"
    },
    {
        "title": "",
        "description": "",
        "name": "foto 1.jpg"
    },
    {
        "title": "",
        "description": "",
        "name": "a01.jpg"
    }
]
我从名称中获取值:

images.each(function(image){                
    alert(image.name);
});
我只需要得到第一个值名

像php:

$images = (array) json_decode($row->images);
$first = true;
foreach ($images as $k => $image) {
    if ($first)
    {
        $firstimage= $image->name;
        $first = false;
    }
}
尝试:


有什么问题:
var firstImageName=images[0]。name?我需要在mootools中获得第一个值名,例如phpI也可以询问您的php代码。要重新表述我的问题:为什么要获取循环中的第一个元素?抱歉,确定第一种方式,请使用PLB建议的方式:
images[0]
是第一个图像。
if (images[0].length){
    var firstImageName = images[0].name;
}