我有一个这样的数组:
[
['translationID'] => 1,
['locale'] => 'nl_BE',
['translation'] => 'U bent aangemeld'
]
[
['translationID'] => 2,
['locale'] => 'de_DE',
['translation'] => 'Sie sind angemeldet als'
]
现在我想要一个包含所有数组的数组,其中键locale = de_DE
首先!这可能吗?
答案 0 :(得分:1)
试试这个,
$arr = array(
array("translationID" => "1","locale" => "nl_BE","translation" => "U bent aangemeld"),
array("translationID" => "2","locale" => "de_DE","translation" => "Sie sind angemeldet als")
);
function cmp($a, $b) {
if ($a["locale"] == $b["locale"]) {
return 0;
}
return ($a["locale"] < $b["locale"]) ? -1 : 1;
}
usort($arr,"cmp");