What i get.
This is the array which i get in my form post form multiple check boxes.
$test1 = array(
'0' => 'test1',
'1' => 'test2',
'2' => 'test3'
);
$test2 = array(
'0' => 'test21',
'1' => 'test22',
'2' => 'test23'
);
$test3 = array(
'0' => 'test31',
'1' => 'test32',
'2' => 'test33'
);
$test4 = array(
'0' => 'test41',
'1' => 'test42',
'2' => 'test43'
);
I need to convert this array in to something like this:
Result needed.
$result_needed = [
'0' => ['0' => 'test1', '1' => 'test21', '2' => 'test31', '3' => 'test41'],
'1' => ['0' => 'test2', '1' => 'test22', '2' => 'test32', '3' => 'test42'],
AND SO ON....
];
What i have tried so far?
I have tried to add this each array in to final array and then used foreach loop on it it get the result but it didn't help. Here is what i tried.
$final = ['test1' => $test1, 'test2' => $test2, 'test3' => $test3, 'test4' => $test4];
echo "<pre>";
$step1 = array();
foreach($final as $key => $val){
$step1[$key] = $val;
}
print_r($step1);
$step1[] = $val;
instead of$step1[$key] = $val;
– B. Desai yesterday