I want to sort an multidimensional array, which has strings as keys and objects as values.
At the moment, this is my code for sorting:
$order = $name = Array();
foreach(get_declared_classes() as $class){
if(get_parent_class($class) == "PaymentGateway"){
$this->gateways[$class::$shortName] = new $class($language);
if($this->gateways[$class::$shortName]->isActive())
$order[$class::$shortName] = intval($this->gateways[$class::$shortName]->getSettings()['order']);
else
$order[$class::$shortName] = 1000;
$name[$class::$shortName] = $this->gateways[$class::$shortName]->getLang('name');
}
}
array_multisort($this->gateways, SORT_ASC, $order, SORT_ASC, $name);
As you can see, the keys of $this->gateways
, $order
and $name
are the same. But it does not work. Does anybody see the mistake?
Debug information:
$name
array(6) {
["barzahlen"]=> string(9) "Barzahlen"
["bitcoin"]=> string(7) "Bitcoin"
["paypal"]=> string(6) "PayPal"
["sofort"]=> string(23) "Sofort-Überweisung"
["stripe"]=> string(6) "Stripe"
["transfer"]=> string(16) "Überweisung"
}
$order
array(6) {
["barzahlen"]=> int(4)
["bitcoin"]=> int(5)
["paypal"]=> int(1)
["sofort"]=> int(2)
["stripe"]=> int(3)
["transfer"]=> int(0)
}
$this->gateways
To long, the same as before...