Q:

Write a PHP program to filter out some array elements with certain key-names

0

Write a PHP program to filter out some array elements with certain key-names

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
$first_array = array('c1' => 'Red', 'c2' => 'Green', 'c3' => 'White', 'c4' => 'Black'); 
$second_array = array('c2', 'c4');
$result = array_diff_key( $first_array, array_flip( $second_array));
print_r($result);
?>

Sample Output:

Array                                                       
(                                                           
    [c1] => Red                                             
    [c3] => White                                           
)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now