Set Theory Union of arrays in PHP

后端 未结 10 858
独厮守ぢ
独厮守ぢ 2020-12-14 06:14

There are 3 operations with sets in mathematics: intersection, difference and union (unification). In PHP we can do this operations with arrays:

  • intersection:
10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 06:50

    Try array_merge:

    array_unique(array_merge($array1, $array2));
    

    PHP Manual

提交回复
热议问题