I'm struggling to create a code that can help me create a table from the below php array. The array name is $associative_array1
array(
'Objective' => array(0 => 'Conversions', 1 => 'Lead Generation', ),
'Gender' => array(0 => 'Male (17.99% cheaper )',
1 => 'Male (6.46% cheaper ) Male (16% cheaper )', ),
'Age' => array(0 => '45-54 (17.99% cheaper )',
1 => '45-54 (6.46% cheaper )35-44 (16% cheaper )', ),
'Placement' => array(0 => 'Mobile Feed (30.8% cheaper) right_hand (46.81% cheaper)',
1 => 'Mobile Feed (12.56% cheaper)', ),
'Device' => array(0 => 'Android (30.8% cheaper) Desktop (46.81% cheaper)',
1 => 'iPhone (12.56% cheaper)', ),
)
Expected Output:
Headings can be taken as constant.
I tried creating code, however that is so bad that it wasn't worth sharing here. Basically, the code did nothing. Sorry, I'm a noob in it and need help from peers.
PHP code
function generateTable2($associative_array,$associative_array1){
echo '
foreach ($associative_array1 as $row=>$value){
echo "
";if(is_array($value))
foreach ($value as $key =>$value2) {
print_r($value2[$key]);
foreach ($value2 as $value3) {
}
# code...
}
}
echo '
';}