値によって配列に頼りたい配列があります。これが既存の配列です。
1 => Array (9)
OrgID => "XXXX"
DOB => "1970-01-01"
PersonID => "111111"
ExpDate => "2013-07-31"
Level => "WELITE"
Status => "Active"
FName => "Jane"
LName => "Doe"
Checked => null
2 => Array (9)
OrgID => "XXXX"
DOB => "1970-01-01"
PersonID => "222222"
ExpDate => "2013-07-31"
Level => "WELITE"
Status => "Active"
FName => "Jane"
LName => "Doe"
Checked => null
3 => Array (9)
OrgID => "XXXX"
DOB => "1970-01-01"
PersonID => "22222"
ExpDate => "2013-07-31"
Level => "WELITE"
Status => "Active"
FName => "Jane"
LName => "Doe"
Checked => null
配列を次のように再分類し、レベルと呼ばれる値に基づいてキーを作成しようとしています:
WELITE => (3)
1 => Array (9)
OrgID => "XXXX"
DOB => "1970-01-01"
PersonID => "111111"
ExpDate => "2013-07-31"
Status => "Active"
FName => "Jane"
LName => "Doe"
Checked => null
2 => Array (9)
OrgID => "XXXX"
DOB => "1970-01-01"
PersonID => "222222"
ExpDate => "2013-07-31"
Status => "Active"
FName => "Jane"
LName => "Doe"
Checked => null
3 => Array (9)
OrgID => "XXXX"
DOB => "1970-01-01"
PersonID => "22222"
ExpDate => "2013-07-31"
Status => "Active"
FName => "Jane"
LName => "Doe"
Checked => null
これが私がこれまでに試したことです:
$sort = array();
foreach($WlevelArray as $k=>$v) {
$sort['Level'][$k] = $v['Level'];
$sort['OrgID'][$k] = $v['OrgID'];
}
array_multisort($sort['Level'], SORT_DESC, $sort['OrgID'], SORT_ASC, $WlevelArray);
しかし、これは 2 つの配列を生成します。