PHP Convert a multiple text entry to a multidimensional array

advertisements

I have 3 text box html (codeigniter)

echo form_input('id',$data['id']);
echo form_input('price',$data['price']);
echo form_input('quantity',$data['quantity']);

and want to convert it to array before sending to another process, like

$items = [
        array(
            'id' => 'item1',
            'price' => 300,
            'quantity' => 1
        ),
        array(
            'id' => 'item2',
            'price' => 100,
            'quantity' => 2
        )
    ];

How it is possible?


Try this with in a for loop

$stack = array(); array_push($stack, array('id'=>'d','value1'=>'e', 'value2' =>'f')); array_push($stack, array('id'=>'x','value1'=>'y', 'value2' =>'z')); print_r($stack); //print array