Boky
Boky

Reputation: 12064

Getting multidimensional array

How can I get an three dimensional array. If I have a hidden field in the form

<input type="hidden" name="txtHidd[productid][productname][productquantity]" />

How can I get it in my form submit page :

I've tried :

foreach ($_POST["txtHidd"] as $idProdChc => $prodIdChc) {
  foreach ($_POST["txtHidd"] as $nameProdChc => $nameChc) {
        foreach($nameChc as $quantity){
        }
  }
}

But it is not working.

Any ideas?

Thanks in advance.

Upvotes: 0

Views: 28

Answers (1)

Mihai Matei
Mihai Matei

Reputation: 24276

It is:

foreach ($_POST["txtHidd"] as $productid => $product) {
    foreach ($product as $productname => $quantity) {
        echo "$productname with product id $productid and quantity " . $quantity['productquantity'];
    }
}

Upvotes: 1

Related Questions