Skip to content

Instantly share code, notes, and snippets.

@bepatrickdavid
Created April 10, 2018 17:36
Show Gist options
  • Save bepatrickdavid/ce9dfc0e6e085421f617f68b56304259 to your computer and use it in GitHub Desktop.
Save bepatrickdavid/ce9dfc0e6e085421f617f68b56304259 to your computer and use it in GitHub Desktop.
PHP: ordinare array di oggetti
//$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