$matching_tickets = ‘‘;
foreach ($list as $kk => $vv) {
$type = substr($vv[‘train_code‘], ‘0‘, ‘1‘);
if ($train_type == $type) {
$matching_tickets[] = $vv; //挑出匹配的车次 余票
}
}
if(!$matching_tickets){ //如果没有匹配的车票..这个变量不存在.使用判断会报错..定义一个默认值比较可靠
$matching_tickets = $tickets[‘result‘][‘list‘];
}
时间: 2024-10-28 21:31:03