Answers for "remove keys found in another array"

PHP
1

how to remove keys in subarray php

print_r(deep_delete_keys($arr,'country'));

function deep_delete_keys($arr, $keys) {
    if (!is_array($keys)) $keys = array($keys);
    $filteredArr = array_diff_key( $arr, array_flip( $keys ) );
    foreach ($filteredArr as &$val) {
        if (is_array($val)) {
            $val = deep_delete_keys($val, $keys);
        }
    }
    return $filteredArr;
}
Posted by: Guest on March-28-2020

Code answers related to "remove keys found in another array"

Browse Popular Code Answers by Language