的结果,最好的办法,我有一个multidimentionla阵列什么是显示这个数组
array(
"Airportbus"=>array(
"NO"=>array(
"from"=>"Barcelona",
"to"=>"Gerona"
)
),
"flight"=>array(
"SK455"=>array(
"from"=>"Gerona",
"to"=>"Stockholm",
"seat"=>"3A"
),
"SK22"=>array(
"from"=>"Stockholm",
"to"=>"New york",
"gate"=>"Gate 22",
"description"=>"Baggage wiil be transfered from your last leg",
"seat"=>"7B"
)
),
"train"=>array(
"78A"=>array(
"from"=>"Madrid",
"to"=>"Barcelona",
"seat"=>"45B"
)
)
);
我要打印这样的结果。
1. Take train 78A from Madrid to Barcelona. Sit in seat 45B.
2. Take the airport bus from Barcelona to Gerona Airport. No seat assignment.
3. From Gerona Airport, take flight SK455 to Stockholm. Gate 45B, seat 3A. Baggage drop at ticket counter 344.
4. From Stockholm, take flight SK22 to New York JFK. Gate 22, seat 7B. Baggage will we automatically transferred from your last leg.
这里的问题是
1.some阵列具有用不同的密钥"gate","description"
多个元件。 2.在结果中打印一些额外的文字,“坐”,“拿”。
我试图用
$message = "";
if(issset($result['key']))
{
$message += " some text ".$result['key']. " some text ",
}
if(issset($result['key2']))
{
$message += " some text ".$result['key2']. " some text ",
}
if(issset($result['key2']))
{
$message += " some text ".$result['key2']. " some text ",
}
我想,如果是低效的,因为每一次新的数组键加我一定要添加更多的代码打印结果。
有没有更好的办法可以做到这样的情况,请大家帮忙。感谢提前:)
至少从一个循环开始。你的数组与你的输出不匹配。你怎么知道订单是火车 - 公共汽车的班机,列车有公共汽车 - 火车 – 2014-09-25 03:17:03
@Dagon能否请你给我一个简单的例子:( – 2014-09-25 03:19:11
@Dagon,mm没有订单:( – 2014-09-25 03:20:03