这样行吗?
<?php
header("Content-Type:text/html;charset=UTF-8");
$doc = new DOMDocument; //xml?始解析
$doc->load("book.xml");
$book = $doc->documentElement;
$airline = $book->getElementsByTagName('airline');
//echo $airline->length-1;
$list = array();
$minP = array();
$arr = array(); //++
$index1 = 0;foreach($airline as $c)
{
$index = 0;
$childnodes = $c->getElementsByTagName('c');
$id = $c->getAttributeNode('id')->nodeValue;
$pro = array();//++
$pro[0] = $id;
$pro[1] = $c->getAttribute('stime');
$pro[2] = $c->getAttribute('atime');
$pro[3] = $c->getAttribute('airrax');
$pro[4] = $c->getAttribute('fulerax');
$pro[5] = $c->getAttribute('food');
$pro[5] = $c->getAttribute('dfly');
$pro[6] = $c->getAttribute('type');
$pro[7] = $c->getAttribute('et');
$pro[8] = $c->getAttribute('stn');
$pro[9] = $c->getAttribute('atn');
$arr[$index1] = $pro;
$index1++;
for($i=$childnodes->length-1; $i>=0;$i--) {
$nixiang=$childnodes->item($i)->GetAttributeNode('p')->nodeValue;
if ($nixiang!="0")
{
$list[$id][$index][0] = $childnodes->item($i)->GetAttributeNode('p')->nodeValue;
$list[$id][$index][1] = $childnodes->item($i)->GetAttributeNode('b')->nodeValue;
$list[$id][$index][2] = $childnodes->item($i)->GetAttributeNode('s')->nodeValue;
$list[$id][$index][3] = $childnodes->item($i)->GetAttributeNode('t')->nodeValue;
$index++;
}
}
sort($list[$id]);
$minP[$id] = $list[$id][0];
}
asort($minP);
$mid=0;
foreach($minP as $id => $val)
{echo $id." ";
for($i = 0;$i < count($arr);$i++){
for($j = 1; $j < count($arr[$i]);$j++){
if($arr[$i][0]==$id){
echo $arr[$i][$j]." ";
}
}
}
echo "<br>";
for ($i = 0; $i<count($list[$id]); $i++)
echo "--".$list[$id][$i][0]." ".$list[$id][$i][1]." ".$list[$id][$i][2]." ".$list[$id][$i][3]."<br>";
$mid++;
}?>
<?php
header("Content-Type:text/html;charset=UTF-8");
$doc = new DOMDocument; //xml?始解析
$doc->load("book.xml");
$book = $doc->documentElement;
$airline = $book->getElementsByTagName('airline');
//echo $airline->length-1;
$list = array();
$minP = array();
$arr = array(); //++
$index1 = 0;foreach($airline as $c)
{
$index = 0;
$childnodes = $c->getElementsByTagName('c');
$id = $c->getAttributeNode('id')->nodeValue;
$pro = array();//++
$pro[0] = $id;
$pro[1] = $c->getAttribute('stime');
$pro[2] = $c->getAttribute('atime');
$pro[3] = $c->getAttribute('airrax');
$pro[4] = $c->getAttribute('fulerax');
$pro[5] = $c->getAttribute('food');
$pro[5] = $c->getAttribute('dfly');
$pro[6] = $c->getAttribute('type');
$pro[7] = $c->getAttribute('et');
$pro[8] = $c->getAttribute('stn');
$pro[9] = $c->getAttribute('atn');
$arr[$index1] = $pro;
$index1++;
for($i=$childnodes->length-1; $i>=0;$i--) {
$nixiang=$childnodes->item($i)->GetAttributeNode('p')->nodeValue;
if ($nixiang!="0")
{
$list[$id][$index][0] = $childnodes->item($i)->GetAttributeNode('p')->nodeValue;
$list[$id][$index][1] = $childnodes->item($i)->GetAttributeNode('b')->nodeValue;
$list[$id][$index][2] = $childnodes->item($i)->GetAttributeNode('s')->nodeValue;
$list[$id][$index][3] = $childnodes->item($i)->GetAttributeNode('t')->nodeValue;
$index++;
}
}
sort($list[$id]);
$minP[$id] = $list[$id][0];
}
asort($minP);
$mid=0;
foreach($minP as $id => $val)
{echo $id." ";
for($i = 0;$i < count($arr);$i++){
for($j = 1; $j < count($arr[$i]);$j++){
if($arr[$i][0]==$id){
echo $arr[$i][$j]." ";
}
}
}
echo "<br>";
for ($i = 0; $i<count($list[$id]); $i++)
echo "--".$list[$id][$i][0]." ".$list[$id][$i][1]." ".$list[$id][$i][2]." ".$list[$id][$i][3]."<br>";
$mid++;
}?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货