【发布时间】:2010-11-01 14:40:35
【问题描述】:
$objDOM = new SimpleXMLElement(XML_FILE_NAME, null, true); // load SimpleXML
$current = $objDOM->xpath('picture');
function sort_current($t1, $t2) {
return strcmp($t2['id'], $t1['id']); // to sort high > low
}
usort($current, 'sort_current');
我怎么会得到这样的输出:
Array ( [0] => SimpleXMLElement 对象 ( [0] => 9 ) [1] => SimpleXMLElement 对象([0] => 8)[2] => SimpleXMLElement 对象 ( [0] => 6 ) [3] => SimpleXMLElement 对象([0] => 5 ) [4] => SimpleXMLElement 对象 ( [0] => 4 ) [5] => SimpleXMLElement 对象 ( [0] => 3 ) [6] => SimpleXMLElement 对象 ( [0] => 2 ) [7] => SimpleXMLElement 对象([0] => 15 ) [8] => SimpleXMLElement 对象 ( [0] => 1 ) [9] => SimpleXMLElement 对象([0] => 0))
我想得到这样的输出:
数组 ( [0] => 8 [1] => 6 [2] => 5 [3] => 4 [4] => 3 [5] => 9 [6] => 2 [7] => 15 [8] => 1 [9] => 0 [10] => )
在没有所有 SimpleXMLElement gubbins 的情况下,我需要进行哪些更改才能获得上述清理后的数组? 干杯, 安迪
【问题讨论】: