[ create a new paste ] login | about

Link: http://codepad.org/Eg2mejZH    [ raw code | output | fork ]

PHP, pasted on May 6:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php 

$array = array(
  array( 
    "product_name"=> "Test Product",
    "product_qty"=>"2.0000",
    "product_price"=>"15.0000",
  ),
  array(
    "product_name"=>"Test 2",
    "product_qty"=>"3.0000",
    "product_price"=>"25.0000",
  ),
);

foreach($array as $pKey=>$product){
   foreach($product as $key=>$option){
       echo "<input type='hidden' name='{$key}_{$pKey}' value='$option'/>\n";
   }
}


Output:
1
2
3
4
5
6
<input type='hidden' name='product_name_0' value='Test Product'/>
<input type='hidden' name='product_qty_0' value='2.0000'/>
<input type='hidden' name='product_price_0' value='15.0000'/>
<input type='hidden' name='product_name_1' value='Test 2'/>
<input type='hidden' name='product_qty_1' value='3.0000'/>
<input type='hidden' name='product_price_1' value='25.0000'/>


Create a new paste based on this one


Comments: