1

こんにちは。私は 7 部屋のユニットを持っていますが、写真が入っているのは 5 部屋だけです。私の目標は、それぞれを適切な場所に表示することです。つまり、1#room->1img、2#room->1img、3#room->3img、4#room->2img、5#room->1img、6 #room->0img, 7#room->0img. これが私の配列です:

Array
(
    [0] => Array
        (
            [large] =>room_galleries/4/large/XWKgkS_a503fd0054f4c6a04e72d95cef5d8b6a.jpg
            [thumb] =>room_galleries/4/thumb/XWKgkS_a503fd0054f4c6a04e72d95cef5d8b6a.jpg
        )

)
Array
(
    [0] => Array
        (
            [large] => room_galleries/13/large/96Hk2r_6e2507fabb7313d18d9a694eda740337.jpg
            [thumb] => room_galleries/13/thumb/96Hk2r_6e2507fabb7313d18d9a694eda740337.jpg
        )

)
Array
(
    [0] => Array
        (
            [large] => room_galleries/38/large/HXJTWL_98e71e7fbc9bab7096f0387b2ffa9ab9.jpg
            [thumb] => room_galleries/38/thumb/HXJTWL_98e71e7fbc9bab7096f0387b2ffa9ab9.jpg
        )

    [1] => Array
        (
            [large] =>room_galleries/38/large/XCquAP_5ccd9c6af4501a1c81b1e6b532100036.jpg
            [thumb] =>room_galleries/38/thumb/XCquAP_5ccd9c6af4501a1c81b1e6b532100036.jpg
        )

    [2] => Array
        (
            [large] => room_galleries/38/large/iDe0SN_6dcf2e3c9dc2180cbed5c98f0adbb0e9.jpg
            [thumb] => room_galleries/38/thumb/iDe0SN_6dcf2e3c9dc2180cbed5c98f0adbb0e9.jpg
        )

)
Array
(
    [0] => Array
        (
            [large] => room_galleries/39/large/FDM6JV_63243ea8328f4ba74200ea3c2d32aa0c.jpg
            [thumb] => room_galleries/39/thumb/FDM6JV_63243ea8328f4ba74200ea3c2d32aa0c.jpg
        )

    [1] => Array
        (
            [large] => room_galleries/39/large/ccNOdB_a12501222468f3e38f05433c002b8851.jpg
            [thumb] => room_galleries/39/thumb/ccNOdB_a12501222468f3e38f05433c002b8851.jpg
        )

)
Array
(
    [0] => Array
        (
            [large] => room_galleries/41/large/IosSy8_e4d6ff02cc21212c6cf6e616619f11b6.jpg
            [thumb] => room_galleries/41/thumb/IosSy8_e4d6ff02cc21212c6cf6e616619f11b6.jpg
        )

)

これが私のphpコードです:

if( !empty( $r['images'])){
            $images = unserialize( $r['images'] );
            foreach( $images as $img ){
                $galleries[$r['roomID']][] = array(
                    'large' => ROOM_GALLERY_HTTP . $r['roomID'] . '/large/' . $img,
                    'thumb' =>  ROOM_GALLERY_HTTP . $r['roomID'] . '/thumb/' . $img,
                );  
            }
            print_r( $galleries[$r['roomID']] ); // the array above
            $tpl->set( 'galleries', $galleries[$r['roomID']] ); // set a tag named galleries for my template
        }

私の問題は、ループの最後の要素を 7 回表示することです。

Array
(
    [0] => Array
        (
            [large] => room_galleries/41/large/IosSy8_e4d6ff02cc21212c6cf6e616619f11b6.jpg
            [thumb] => room_galleries/41/thumb/IosSy8_e4d6ff02cc21212c6cf6e616619f11b6.jpg
        )

)

助言がありますか?

4

0 に答える 0