$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');
为什么我得到这样的输出:PHP数组格式
阵列([0] => SimpleXMLElement对象 ([0] => 9),[1] => SimpleXMLElement Object([0] => 8)[2] => SimpleXMLElement对象([0] => 6) [3] => SimpleXMLElement对象([0] => 5)对象([0] => 4)[5] => SimpleXMLElement对象([0] => 3)[>] SimpleXMLElement对象([0] => 2) [7] => SimpleXMLElement对象([0] => 15)[8] => SimpleXMLElement对象([0] => 1)[9] => SimpleXMLElement Object([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? 干杯, Andy
(字符串)$值“身份证”]的伎俩,干杯! – Andy 2010-11-01 15:16:46