2010-09-06 66 views
1
Array ([Screens] => 
    Array ([0] => 
     Array ([ SPKRS ] => 
      Array ([price] => 455 
        [quantity] => 3 
        [image] => 

       ) 
     )  
    ) [Software] => Array 
      ([0] => Array 
      ([Pricing] => 
       Array ([price] => 2 
         [quantity] => 2 
         [image] => SOFTWARE.png 

       [ALDELO FOR RESTAURANTS] => Array 
         ([price] => 535 
         [quantity] => 1 
         [image] => 

))) [Networking] => Array 
.... 

數組是$產品通過數組循環和抓住關鍵

<?php foreach ($products as $product): ?> 
    <div class="box-active"> 
    <div class="line"> 
    <div class="text left"> 
    <p><?php print key($product); ?></p> 

它打印0所有三個

+0

您的數組密鑰無效。你可以使用數組的var_dump來替換你的問題中的代碼嗎? – 2010-09-06 22:07:08

回答

3

試試這個:

<?php foreach ($products as $key => $product): ?> 
    <div class="box-active"> 
    <div class="line"> 
    <div class="text left"> 
    <p><?php print $key; ?></p> 

manual page on foreach