PHP解析xml文件我怎么从小到大排序?请看代码!在线等候…………急…… 楼主的代码好像和这个一样啊,http://topic.csdn.net/u/20090312/10/d871d7e8-48a8-4e71-8151-817e61771faa.html 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <?$doc = new DOMDocument; //xml?始解析$doc->load("book.xml");$book=$doc->documentElement; $airline =$book->getElementsByTagName('airline'); $list = array(); $index = 0; foreach($airline as $c) { $childnodes = $c->getElementsByTagName('c'); for($i=$childnodes->length-1; $i>=0;$i--) { $nixiang=$childnodes->item($i)->GetAttributeNode('p')->nodeValue; if ($nixiang!="0") { $p=$childnodes->item($i)->GetAttributeNode('p')->nodeValue; } $list[$index] = $p; $index++; }}sort($list); for($i = 0; $i < count($list);$i++ ){ echo $list[$i]."<br>";}?> 组成二维数组$roughData后,就可以这么做方法:(1)提取accuracy列数组foreach ($roughData as $key => $row) { $accuracy[$key] = $row['accuracy'];}(2)进行排序array_multisort($accuracy, SORT_ASC,$roughData); 我要做一个商城系统,请高手指点 使用fetch_assoc()和fetch_object()出错 求sql语句 列表框的change事件,如可用PHP处理 关于php判断问题 怎么才能检查出sql语句执行错误! windows下如何解决PHP调用的外部程序超时阻塞问题 PHP中如何分页? 用main()可以直接的发送邮件吗? PHP curl响应参数与响应header 中的参数值获取 有关array_intersect() 算交集的问题 大家一般是怎么建站的
$doc = new DOMDocument; //xml?始解析
$doc->load("book.xml");
$book=$doc->documentElement;
$airline =$book->getElementsByTagName('airline');
$list = array();
$index = 0;
foreach($airline as $c)
{
$childnodes = $c->getElementsByTagName('c'); for($i=$childnodes->length-1; $i>=0;$i--) {
$nixiang=$childnodes->item($i)->GetAttributeNode('p')->nodeValue;
if ($nixiang!="0")
{
$p=$childnodes->item($i)->GetAttributeNode('p')->nodeValue;
}
$list[$index] = $p;
$index++;
}}
sort($list);
for($i = 0; $i < count($list);$i++ ){
echo $list[$i]."<br>";
}
?>
方法:
(1)提取accuracy列数组foreach ($roughData as $key => $row) {
$accuracy[$key] = $row['accuracy'];
}(2)进行排序
array_multisort($accuracy, SORT_ASC,$roughData);