Is there a PHP function to remove any/all key/value pairs that have a certain value from an array?

前端 未结 5 1949
予麋鹿
予麋鹿 2021-01-26 11:27

I think questions like this are the reason why I don\'t like working with PHP. The manual is good, if you can find what you are looking for. After reading through the Array Func

5条回答
  •  佛祖请我去吃肉
    2021-01-26 11:53

    array_diff is what you want.

    $array1 = array("a" => "green", "red", "blue", "red");
    $array2 = array("b" => "green", "yellow", "red");
    $result = array_diff($array1, $array2);
    

    Result: "blue".

提交回复
热议问题