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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -