Created
April 10, 2018 17:36
-
-
Save bepatrickdavid/ce9dfc0e6e085421f617f68b56304259 to your computer and use it in GitHub Desktop.
PHP: ordinare array di oggetti
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$d è un oggetto stdClass | |
//$newd = new stdClass; | |
//$newd->ID = "MAIN"; | |
//$newd->NAME = "Look - The Concept Factory"; | |
//$newd->ADDRESS = "Zona industriale Villanova, 19 32013 Longarone (BL) ITALY"; | |
//$newd->TEL = "+390437573060"; | |
//$newd->MAIL = "[email protected]"; | |
//$newd->WEBSITE = "www.lookocchiali.it"; | |
//$newd->DISTANCE = ""; | |
//$newd->DURATION = ""; | |
//$newd->NUMBER = ""; | |
//$newd->MAPS = "https://www.google.it/maps/place/Look+the+Concept+Factory/"; | |
// ordino per il campo number | |
array_push($allDistance,$d); | |
//var_dump($allDistance); | |
usort ($allDistance, function ($a, $b){ | |
if ($a->NUMBER == $b->NUMBER) { | |
return 0; | |
} | |
return ($a->NUMBER < $b->NUMBER) ? -1 : 1; | |
}); | |
//var_dump($allDistance); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment