hola a todos, tengo la siguiente duda con respecto a ordenar un array multidimensional por un campo de este mismo array, me explico deseo ordenarlo por el campo padre aca dejo el ejemplo.
Código HTML:
function create_sitemap($sitemap){
$xml = file_exists('sitemap.xml') ? $xml = simplexml_load_file('sitemap.xml'): exit('Failed to open sitemal.xml.');
$xml = uasort($xml, 'alphabetize');
print($xml);
foreach($xml as $site){
echo '<div><a href="'.$site->loc.'">'$site->loc.'</a>' .$site->padre.'</div>';
}
}
function alphabetize($a, $b){
return strcmp($a->padre, $b->padre);
}
algo asi es mi array
SimpleXMLElement Object ( [url] => Array ( [0] => SimpleXMLElement Object ( [loc] => http://www.aerocom.net.au/index.php?id=download [padre] => SimpleXMLElement Object ( ) [lastmod] => 2010-04-06T10:15:25+00:00 [changefreq] => weekly [priority] => 0.5 ) [1] => SimpleXMLElement Object ( [loc] => http://www.aerocom.net.au/index.php?id=faq [padre] => SimpleXMLElement Object ( ) [lastmod] => 2010-04-05T13:57:35+00:00 [changefreq] => weekly [priority] => 0.5 ) [2] => SimpleXMLElement Object ( [loc] => http://www.aerocom.net.au/index.php?id=privacy-policy [padre] => SimpleXMLElement Object ( ) [lastmod] => 2010-03-22T15:42:02+00:00 [changefreq] => weekly [priority] => 0.5 ) [3] => SimpleXMLElement Object ( [loc] => http://www.aerocom.net.au/index.php?id=24-x-7-support [padre] => SimpleXMLElement Object ( ) [lastmod] => 2010-03-17T10:26:03+00:00 [changefreq] => weekly [priority] => 0.5 )
Gracias de antemano, saludos