Built in support for sets in PHP?

后端 未结 5 1031
一生所求
一生所求 2020-12-05 16:45

I\'m looking for a simple way to create an array in php that will not allow duplicate entries, but allows for easy combining of other sets or arrays.

I\'m mostly int

5条回答
  •  醉梦人生
    2020-12-05 17:32

    Just an idea, if you use the array keys instead of values, you'll be sure there are no duplicates, also this allows for easy merging of two "sets".

    $set1 = array ('a' => 1, 'b' => 1, );
    $set2 = array ('b' => 1, 'c' => 1, );
    $union = $set1 + $set2;
    

提交回复
热议问题