php array html,PHP array to HTML table

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:7v6B7.png

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 '

';

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值