php - multidimensional array with unknow key's -


i'm having multidimensional array don't know keys , need key's value.

my array database filled:

$rows[$product_id][$productgroup_id] = $amount 

so array example filled 2 products:

$rows[108][3] = 2 $rows[2][5] = 4 

so array holds 2 product:

  • product_id 108 productgroup 3 amount of 2
  • product_id 2 productgroup 5 amount of 4

now need walk through array , need keys , amount. i'm thinking in foreach loop

foreach($rows $row){   foreach($row $key => $value){     echo "key:".$key." value: ".$value."<br>";"   } } 

but echo's first key, product_id , amount. need product_id, productgroup_id , amount. how productgroup_id?

the code have far there, need extract both id's foreach loop.

foreach($rows $product_id => $group){   foreach($group $productgroup_id => $value){     echo "product id:" . $product_id . " group:".$productgroup_id." value: ".$value."<br>";"   } } 

Comments

Popular posts from this blog

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -