我有一个数组,我想按值诉诸数组。这是现有的数组:
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
我正在尝试将数组转换为以下内容,并根据名为 level 的值创建一个键:
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);
但这会产生两个数组。