示例这里只有2个参数工作正常,这段代码工作正常,因为我只传递2个参数到array_combine
$b_destinations = unserialize( base64_decode( $rs['b_destinations'] ) );
$b_nights = unserialize( base64_decode( $rs['b_nights'] ) );
foreach (array_combine($b_destinations[0], $b_nights[0]) as $desti=>$nights)
{
echo"
<tr><td>Detination</td><td> ".$desti."</td><td>Nights : ".$nights."</td></tr>";
}
&#13;
但我想在这里显示多个数组值
$b_hdest = unserialize( base64_decode( $rs['b_hdest'] ) );
$b_hname = unserialize( base64_decode( $rs['b_hname'] ) );
$b_hadd = unserialize( base64_decode( $rs['b_hadd'] ) );
$b_hphone = unserialize( base64_decode( $rs['b_hphone'] ) );
$b_hin = unserialize( base64_decode( $rs['b_hin'] ) );
$b_hout = unserialize( base64_decode( $rs['b_hout'] ) );
$b_hroom = unserialize( base64_decode( $rs['b_hroom'] ) );
$b_hmeal = unserialize( base64_decode( $rs['b_hmeal'] ) );
$b_haextra = unserialize( base64_decode( $rs['b_haextra'] ) );
$b_hcextra = unserialize( base64_decode( $rs['b_hcextra'] ) );
$b_hspecial = unserialize( base64_decode( $rs['b_hspecial'] ) );
$b_hincl = unserialize( base64_decode( $rs['b_hincl'] ) );
$hcnt=1;
//which method or function use here to display this desired result
foreach or any other method loop
{
echo "<tr><td colspan='4'>Hotel Details ".$hcnt."</td></tr>
<tr><td>Destination : ".$b_hdest."</td><td>Hotel Name : ".$b_hname."</td><td>Add : ".$b_hadd."</td><td>Phone : ".$b_hphone."</td></tr>
<tr><td>Check In : ".$b_hin."</td><td>Check Out : ".$b_hout."</td><td>Rooms : ".$b_hroom."</td><td>Meal : ".$b_hmeal."</td></tr>
<tr><td>Extra Adult : ".$b_haextra."</td><td>Extra Child : ".$b_hcextra."</td><td>Special : ".$b_hspecial."</td><td>Inclusion : ".$b_hincl."</td></tr>";
$hcnt++;
}
&#13;
我希望得到的结果是这样的。 我使用过array_combine,但它仅适用于2个paramneters 有没有其他方法或方法来做到这一点。
.mytable table, td, th {
border: 1px solid #ddd;
text-align: left;
}
.mytable table {
border-collapse: collapse;
width: 100%;
}
.mytable th, td {
padding: 15px;
}
&#13;
<table class='mytable'>
<tr><td colspan='4'>Hotel Details 1</td></tr>
<tr><td>Destination : Kerala</td><td>Hotel Name : Beach Resort</td><td>Add : hotel address</td><td>Phone : 7447344789</td></tr>
<tr><td>Check In : 10/11/2017</td><td>Check Out : 15/11/2017</td><td>Rooms : 4</td><td>Meal : MAP</td></tr>
<tr><td>Extra Adult : 1</td><td>Extra Child : 1</td><td>Special : no special</td><td>Inclusion : no inclusion</td></tr>
<tr><td colspan='4'>Hotel Details 2</td></tr>
<tr><td>Destination : Kerala</td><td>Hotel Name : Beach Resort</td><td>Add : hotel address</td><td>Phone : 7447344789</td></tr>
<tr><td>Check In : 10/11/2017</td><td>Check Out : 15/11/2017</td><td>Rooms : 4</td><td>Meal : MAP</td></tr>
<tr><td>Extra Adult : 1</td><td>Extra Child : 1</td><td>Special : no special</td><td>Inclusion : no inclusion</td></tr>
<tr><td colspan='4'>Hotel Details 3</td></tr>
<tr><td>Destination : Kerala</td><td>Hotel Name : Beach Resort</td><td>Add : hotel address</td><td>Phone : 7447344789</td></tr>
<tr><td>Check In : 10/11/2017</td><td>Check Out : 15/11/2017</td><td>Rooms : 4</td><td>Meal : MAP</td></tr>
<tr><td>Extra Adult : 1</td><td>Extra Child : 1</td><td>Special : no special</td><td>Inclusion : no inclusion</td></tr>
</table>
&#13;
答案 0 :(得分:0)
尝试以下操作并告诉我
for($i=0;$i<count($b_hdest[0]);$i++){
echo"
<tr><td>Hotel Details ".($i+1)."</td></tr>
<tr><td>Location : ".$b_hdest[0][$i]."</td><td>Name : ".$b_hname[0][$i]."</td><td>Address : ".$b_hadd[0][$i]."</td><tr>
<tr><td>Phone : ".$b_hphone[0][$i]."</td><td>CheckIn : ".$b_hin[0][$i]."</td><td>CheckOut : ".$b_hout[0][$i]."</td><tr>
<tr><td>Rooms : ".$b_hroom[0][$i]."</td><td>Meals : ".$b_hmeal[0][$i]."</td><td>Extra Adult : ".$b_haextra[0][$i]."</td><tr>
<tr><td>Extra Child : ".$b_hcextra[0][$i]."</td><td>Special : ".$b_hspecial[0][$i]."</td><td>Inclusion : ".$b_hincl[0][$i]."</td><tr>
";
}
&#13;