Order object simplexml_load_file by field of this.
- by ronsandova
Hi i have a problems with simplexml_load_file, i'm not pretty sure how to do to order my array by a $item-padre.
I need to do foreach and order by $item-padre.=, i don't know how to do this.
function create_sitemap($sitemap){
$xml = file_exists('sitemap.xml') ? $xml = simplexml_load_file('sitemap.xml'): exit('Failed to open sitemal.xml.');
$xml = uasort($xml, function($a,$b){ return strcmp($a-padre, $b-padre); });
foreach ($xml-url as $item) {
echo "" . $item-loc. "";
echo "" . $item-padre . "";
}
}
Thanks in advance.