我有 5 个数组
$array1 = array('ar1_1','ar1_2','ar1_3','ar1_4');
$array2 = array('ar2_1','ar2_2','ar2_3','ar2_4','ar2_5');
$array3 = array('ar3_1','ar3_2','ar3_3','ar3_4','ar3_5','ar3_6');
$array4 = array('ar4_1','ar4_2','ar4_3','ar4_4');
$array5 = array('ar5_1','ar5_2','ar5_3');
$loc = array('AM','IN','US');
我想以某种方式显示它;
<table>
<tr class="d1 vevent">
<td>
<b><abbr class="dtstart" title="' . $array1 . '">' . $array2 . '</abbr></b> <br>' . $array3 . '</td>
<td>
<span class="summary">' . $array4 . ' - ' . $array5 . '</span>
<span class="location">' . $loc . '</span>
</td>
</tr>
</table>
有什么解决办法吗?
我尝试过 for 循环、foreach 循环、zip、array_merge 和 array_combine,但无法获得预期的结果。
我试过的代码:
echo '<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tbody>
<tr class="toprow">
<td><strong>Date </strong></td>
<td><strong> Details</strong></td>
</tr>';
/*
foreach(array_combine($date, $time) as $time1 => $date1)
{
@$date1 = split('[()]', $date1);
echo $time1. $date1[1]. "<br />";
} */
$result = count($match_no);
for($i=0; $i<$result; $i++) {
echo '
<tr class="d1 vevent">
<td>
<b><abbr class="dtstart" title="';
echo trim($date[0]);
echo '">';
echo $date[0];
echo '</abbr></b> <br>';
foreach($time as $time1)
{
@$time1 = split('[()]', $time1);
echo $time1[1];
}
echo '</td>
<td>
<span class="summary">';
echo $match_no[0];
echo ' - <a href="';
echo '#" class="url">';
echo $team[0];
echo ' vs ';
echo $team[1];
echo '</a></span>';
echo '<span class="location">';
echo $location;
echo '</span>';
echo '</td>
</tr>';
}
echo '</table>';
这是我尝试过的代码,但是每次 for 循环迭代时 foreach 循环都会迭代多次。