array_multisort无效

时间:2015-06-03 15:24:09

标签: php arrays 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);

如您所见,$this->gateways$order$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" 
  }

$顺序

array(6) { 
      ["barzahlen"]=> int(4) 
      ["bitcoin"]=> int(5) 
      ["paypal"]=> int(1) 
      ["sofort"]=> int(2) 
      ["stripe"]=> int(3) 
      ["transfer"]=> int(0) 
  }

$这 - >网关

长,和以前一样......

0 个答案:

没有答案
相关问题