PHP unique array by value?

后端 未结 6 676
南方客
南方客 2020-12-03 15:22

I have an array in PHP that looks like this:

  [0]=>
       array(2) {
           [\"name\"]=>
              string(9) \"My_item\"
           [\"url\"]         


        
6条回答
  •  温柔的废话
    2020-12-03 15:28

    Serialisation is very useful for simplifying the process of establishing the uniqueness of a hierarchical array. Use this one liner to retrieve an array containing only unique elements.

    $unique = array_map("unserialize", array_unique(array_map("serialize", $input)));
    

提交回复
热议问题