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)', ),
)
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 '<table width="620" class="optimization_table" border="1" cellspacing="0" cellpadding="0"><thead><tr><th colspan=2>';
echo implode('</th><th colspan=2>', array_keys(current($associative_array)));
echo '</th></tr></thead><tbody>';
foreach ($associative_array1 as $row=>$value){
echo "<td>";
if(is_array($value))
foreach ($value as $key =>$value2) {
print_r($value2[$key]);
foreach ($value2 as $value3) {
}
# code...
}
}
echo '</tbody></table>';
}

var_exportof your PHP array, it will be easier for us to help you then - php.net/var_export .. then edit your post with that array instead of what you originally posted.$associative_arrayor$associative_array1?