Hey guys. I am creating an application that require dynamic fields generated by javascript. I have managed to create the forms the database and pretty much may things. I come to hit a roadblock with this array problem. I am trying to get the data from the browser by checking which one contain more than one value and then transverses through another array this one
$nyingi = [ 'location_' => ['text' => 'loc_txt','priority' => 'loc_order'],
'photo_' => ['path' => 'p_txt'],
'video_' => ['path' => 'v_txt'],
'product_' => ['p_id' => 'pt_q', 'text' => 'pt_txt', 'expire' => 'pt_xpr', 'title' => 'pt_tt'],
'service_' => ['p_id' => 'st_q', 'text' => 'st_txt', 'expire' => 'st_xpr', 'title' => 'st_tt'],
'hours_' => ['time1' => 't1', 'time2' => 't2', 'type' => 'tt'],
'map_' => ['text' => 'm_txt']
];
use this loop
foreach($nyingi as $ins => $vl){
foreach($vl as $fld => $box){
$uwazi = $this->input->post($box);
if(is_array($uwazi) && 1<count($uwazi)){
foreach($uwazi as $bb){
$one[$ins][$fld][] = $bb;
}
}
}
}
and get this result
Array
(
[location_] => Array
(
[text] => Array
(
[0] => Main Office
[1] => Branch 1
[2] => Branch 2
)
[priority] => Array
(
[0] => 1
[1] => 2
[2] => 3
)
)
[photo_] => Array
(
[path] => Array
(
[0] => Photo 1
[1] => Photo 2
[2] => Photo 3
)
)
[video_] => Array
(
[path] => Array
(
[0] => Video 1
[1] => Video 2
[2] => Video 3
)
)
what I want to get is this
Array
(
[location_] => Array
(
[text] => Main Office
[priority] => 1
)
[photo_] => Array
(
[path] => Photo 1
)
[video_] => Array
(
[path] => Video 1
)
[product_] => Array
(
[p_id] =>Product 2 photo
[text] => Product 2 Description
[expire] => Product 2 expire
[title] => Product 2
)
)
)
for each one of those. Any ideas where I am getting wrong.