很難如此解釋這裏是一個例子:如何通過一個鍵的值在PHP排序關聯數組的數組
$strings = array(
array("languageCode" => "ES", "string" => "hola"),
array("languageCode" => "EN", "string" => "hello"),
array("languageCode" => "IT", "string" => "ciao"),
array("languageCode" => "CHS", "string" => "您好"),
);
我想串由languageCode
值,通過定義的順序進行排序:
function magicStringOrder(array $strings, array $languageCodeOrder){
// ....
return $strings;
}
$strings = magicStringOrder($strings, array('EN', 'IT'));
$strings = array(
array("languageCode" => "EN", "string" => "hello"),
array("languageCode" => "IT", "string" => "ciao"),
array("languageCode" => "ES", "string" => "hola"),
array("languageCode" => "CHS", "string" => "您好"),
);
還有magicStringOrder
?
我現在知道這是一個簡單的問題來解決幾個循環。我需要一個非常快速的功能(它被稱爲很多次,與大陣)
對於在您的語言編碼器中沒有條目的值,您有什麼期望? – 2015-02-08 11:26:26
@MarkBaker如果定義的順序是假定的位置,否則保持其位置 – 2015-02-08 11:34:46