0

私は配列を持っています、私はそれをループします:

foreach($input['gallery'] as $galleryImg) {
}

しかし、ループ内では、$input['gallery'] に対して何かを行う以外に、$input['galleryData'] に対しても何かをしたいと考えています。

同じループ内でギャラリー データ配列の各部分にアクセスするにはどうすればよいですか?

foreach($input['gallery'] as $galleryImg) {

     //do something for $galleryImg
     //do something for $input['galleryData'][$i?]
}

入力のダンプ:

{
    ["title"]=> string(0) ""
    ["date"]=> string(10) "30-09-2013"
    ["content"]=> string(0) ""
    ["galleryData"]=> string(149)
        "[
            {
                "comment":"$(this).data('comment')"
                ,"youTube":"$(this).data('youtube')"
            },
            {
                "comment":"$(this).data('comment')"
                ,"youTube":"$(this).data('youtube')"
            }
        ]"
    ["cover"]=> object(Symfony\Component\HttpFoundation\File\UploadedFile)#9 (7)
        {
            ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false)
            ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(14) "smallbunny.jpg"
            ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(10) "image/jpeg"
            ["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(2383)
            ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0)
            ["pathName":"SplFileInfo":private]=> string(14) "/tmp/phpBXVl5Q"
            ["fileName":"SplFileInfo":private]=> string(9) "phpBXVl5Q"
        }
    ["gallery"]=> array(2)
        {
            [0]=> object(Symfony\Component\HttpFoundation\File\UploadedFile)#10 (7)
                {
                    ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false)
                    ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(9) "6empj.jpg"
                    ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(10) "image/jpeg"
                    ["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(116985)
                    ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0)
                    ["pathName":"SplFileInfo":private]=> string(14) "/tmp/phpsl4sNd"
                    ["fileName":"SplFileInfo":private]=> string(9) "phpsl4sNd"
                }
            [1]=> object(Symfony\Component\HttpFoundation\File\UploadedFile)#11 (7)
                {
                    ["test":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> bool(false)
                    ["originalName":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(14) "smallbunny.jpg"
                    ["mimeType":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> string(10) "image/jpeg"
                    ["size":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(2383)
                    ["error":"Symfony\Component\HttpFoundation\File\UploadedFile":private]=> int(0)
                    ["pathName":"SplFileInfo":private]=> string(14) "/tmp/phpA1u3vA"
                    ["fileName":"SplFileInfo":private]=> string(9) "phpA1u3vA"
                }
        }
}
4

1 に答える 1