I am very new in PHP & would like to revamp below multidiemensional array. These array i am getting from JSON submit of a FORM with lots of 'name' & 'value' but i need to spread out few set of values. Here i only given a example that is similar of my work.
$formValues = array(
array(
'name' => 'name-agent-1',
'value' => 'austin'
),
array(
'name' => 'company-agent-1',
'value' => 'Samsung'
),
array(
'name' => 'phone-agent-1',
'value' => '889410'
),
array(
'name' => 'mail-agent-1',
'value' => 'abc@mail.com'
),
array(
'name' => 'name-agent-2',
'value' => 'Justin'
),
array(
'name' => 'company-agent-2',
'value' => 'Nokia'
),
array(
'name' => 'phone-agent-2',
'value' => '332100'
),
array(
'name' => 'mail-agent-2',
'value' => 'xyz@mail.com'
),
array(
'name' => 'name-agent-3',
'value' => 'stefen'
),
array(
'name' => 'company-agent-3',
'value' => 'Motorolla'
),
array(
'name' => 'phone-agent-3',
'value' => '8744520'
),
array(
'name' => 'mail-agent-3',
'value' => 'tyu@mail.com'
)
);
From the above example of Multi-dimensional array i would like to re-build on below format:
Array ( [1] => Array ( [name-agent-1] => austin [company-agent-1] => Samsung [phone-agent-1] => 889410 [mail-agent-1] => abc@mail.com ) [2] => Array ( [name-agent-2] => Justin [company-agent-2] => Nokia [phone-agent-2] => 332100 [mail-agent-2] => xyz@mail.com ) [3] => Array ( [name-agent-3] => stefen [company-agent-3] => Motorolla [phone-agent-3] => 8744520 [mail-agent-3] => tyu@mail.com ) )
I need your the shortest & easiest way to make this happen. Please help and appreciated the suggestion that makes sense. Thanks in advance.