note 106707 deleted from function.asort by thiago

From: Date: Wed, 30 Nov 2011 13:08:44 +0000
Subject: note 106707 deleted from function.asort by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-184823@lists.php.net to get a copy of this message
Note Submitter: Steve Tauber ---- asort will not work if some of your sub elements are SimpleXMLElement Objects: //Pseudo code $unsorted_mixed_array = Array ( [Foo] => Array ( [label] => SimpleXMLElement Object ( [0] => Item Foo ) [media] => foo.jpg ) [Bar] => Array ( [label] => SimpleXMLElement Object ( [0] => Item Bar ) [media] => bar.jpg ) ) //Pseudo code $unsorted_array = Array ( [Foo] => Array ( [label] => Item Foo [media] => foo.jpg ) [Bar] => Array ( [label] => Item Bar [media] => bar.jpg ) ) //Sort both arrays asort($unsorted_mixed_array); asort($unsorted_array); //Now on the output $unsorted_mixed_array has not changed at all: $unsorted_mixed_array: Array ( [Foo] => Array ( [label] => SimpleXMLElement Object ( [0] => Item Foo ) [media] => foo.jpg ) [Bar] => Array ( [label] => SimpleXMLElement Object ( [0] => Item Bar ) [media] => bar.jpg ) ) $unsorted_mixed_array: Array ( [Bar] => Array ( [label] => Item Bar [media] => bar.jpg ) [Foo] => Array ( [label] => Item Foo [media] => foo.jpg ) )

« previous php.notes (#184823) next »