php获取数组索引

时间:2013-04-04 11:01:46

标签: php arrays for-loop

嗨我有一个数组,输出如下:

Array
(
    [0] => Array
        (
            [cat1_id] => 1
            [sub_cat1_id] => 1065
            [b_subcat_name] => Asian
        )

    [1] => Array
        (
            [cat3_id] => 1
            [sub_cat3_id] => 1011
            [b_subcat_name] => Barbeque
        )

)

我使用for循环来输出这些数据,但是如何在html上输出sub_cat1_idsub_cat2_id名称?感谢

1 个答案:

答案 0 :(得分:1)

你必须在循环内循环并获得keyName

            foreach($UpperLoop as $l1)
              foreach($l1 as $l2)
                 { here you will get the key Name }