Answer the question
In order to leave comments, you need to log in
Php how to remove certain values in an array?
There is an array $arResult["arClinics"], for example:
Array
(
[0] => Array
(
[ID] => 10882
[~ID] => 10882
[PROPERTY_SPECIALIZATIONS_VALUE] => Array
(
)
[~PROPERTY_SPECIALIZATIONS_VALUE] => Array
(
)
[PROPERTY_SPECIALIZATIONS_DESCRIPTION] => Array
(
)
[~PROPERTY_SPECIALIZATIONS_DESCRIPTION] => Array
(
)
[PROPERTY_SPECIALIZATIONS_PROPERTY_VALUE_ID] => Array
(
)
[~PROPERTY_SPECIALIZATIONS_PROPERTY_VALUE_ID] => Array
(
)
)
[1] => Array
(
[ID] => 10883
[~ID] => 10883
[PROPERTY_SPECIALIZATIONS_VALUE] => Array
(
)
[~PROPERTY_SPECIALIZATIONS_VALUE] => Array
(
)
[PROPERTY_SPECIALIZATIONS_DESCRIPTION] => Array
(
)
[~PROPERTY_SPECIALIZATIONS_DESCRIPTION] => Array
(
)
[PROPERTY_SPECIALIZATIONS_PROPERTY_VALUE_ID] => Array
(
)
[~PROPERTY_SPECIALIZATIONS_PROPERTY_VALUE_ID] => Array
(
)
)
[2] => Array
(
[ID] => 10884
[~ID] => 10884
[PROPERTY_SPECIALIZATIONS_VALUE] => Array
(
[0] => 11281
[1] => 11254
[2] => 10885
[3] => 10895
[4] => 10887
[5] => 10886
[6] => 10888
[7] => 21736
)
[~PROPERTY_SPECIALIZATIONS_VALUE] => Array
(
[0] => 11281
[1] => 11254
[2] => 10885
[3] => 10895
[4] => 10887
[5] => 10886
[6] => 10888
[7] => 21736
)
[PROPERTY_SPECIALIZATIONS_DESCRIPTION] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
)
foreach($arResult["arClinics"] as $key => $item){
$arResult["arClinics"]["ITEMS"] = $item["ID"];
$arResult["arClinics"]["ITEMS"] = $item["PROPERTY_SPECIALIZATIONS_VALUE"];
}
Answer the question
In order to leave comments, you need to log in
Below is a possible solution:
foreach($arClinics as $id => $Clinic) {
$arClinics[$id] = array_filter(
$Clinic,
function($key) {
return $key == 'ID' || $key == 'PROPERTY_SPECIALIZATIONS_VALUE';
},
ARRAY_FILTER_USE_KEY
);
}
1) unset
2) as $key => $item hints that you need to use the current key for verification, and for anset.
3) You can simply transfer these properties to a new array if the structure of the old one does not suit you.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question