I have this array that has two $rows:
这个数组有两个$行:
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:
这是来自代码的输出,你可以看到表格似乎不对齐:
1 个解决方案
#1
0
You need to loop over the whole array and then loop over the inner data as well. Simply you need two foreach loops.
您需要对整个数组进行循环,然后对内部数据进行循环。你只需要两个foreach循环。
$rows = $vars;
foreach ($rows as $occ => $outer ) {
foreach ($outer as $key => $value) {
if (strpos($key, 'views') === 0 && $value =='') {
unset($vars[$occ][$key]);
}
}
}
#1
0
You need to loop over the whole array and then loop over the inner data as well. Simply you need two foreach loops.
您需要对整个数组进行循环,然后对内部数据进行循环。你只需要两个foreach循环。
$rows = $vars;
foreach ($rows as $occ => $outer ) {
foreach ($outer as $key => $value) {
if (strpos($key, 'views') === 0 && $value =='') {
unset($vars[$occ][$key]);
}
}
}