Stack Overflow на русском Asked by VALIKHAN on December 2, 2021
Имеется массив. Нужно вывести уникальные значения массива по REQUESTID
Array
(
[0] => Array
(
[REQUESTID] => 13
[STATUSID] => 1
[DATAORDER] => 3
)
[1] => Array
(
[REQUESTID] => 13
[STATUSID] => 2
[DATAORDER] => 1
)
[2] => Array
(
[REQUESTID] => 13
[STATUSID] => 1
[DATAORDER] => 2
)
[3] => Array
(
[REQUESTID] => 15
[STATUSID] => 1
[DATAORDER] => 2
)
)
Результат перебора:
Array
(
[2] => Array
(
[REQUESTID] => 13
[STATUSID] => 1
[DATAORDER] => 2
)
[3] => Array
(
[REQUESTID] => 15
[STATUSID] => 1
[DATAORDER] => 2
)
)
$arr = array(
"0" => array(
"REQUESTID" => "13",
"STATUSID" => "1",
"DATAORDER" => "3"
),
"1" => array
(
"REQUESTID" => "13",
"STATUSID" => "2",
"DATAORDER" => "1"
),
"2" => array
(
"REQUESTID" => "13",
"STATUSID" => "1",
"DATAORDER" => "2"
),
"3" => array
(
"REQUESTID" => "15",
"STATUSID" => "1",
"DATAORDER" => "2"
)
);
foreach ($arr as $key => $value) {
if($value["STATUSID"]=="1" or $value["STATUSID"]=="3" or $value["DATAORDER"]=="2"){
}else{
unset($arr[$key]);
}
}
foreach ($arr as $key => $value) {
$res[$value["REQUESTID"]]=$value;
}
print_r($res);
?>
Answered by Bloom on December 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP