两个数组:如果第一个数组中的键为空,则将第二个数组中的相同键设置为空?

I have this array that has two $rows:

enter image description here

I'd like the second array's display to be based on the first array but I don't think I have it set up properly:

$rows = &$vars['rows'];
foreach ($rows[0] as $key => $value) {
  if (strpos($key, 'views') === 0 && empty($value)) {
        $rows[1][$key] = '';
        unset($vars['header'][$key]);
  }
}

This is the output from the code, you can see the table doesn't seem aligned properly:

enter image description here

You need to loop over the whole array and then loop over the inner data as well. Simply you need two foreach loops.

$rows = $vars;
foreach ($rows as $occ => $outer ) {
    foreach ($outer as $key => $value) {
        if (strpos($key, 'views') === 0 && $value =='') {
            unset($vars[$occ][$key]);
        }
    }
}