tags: #php #data-structures #set ## Sets [Sets](https://github.com/jakewhiteley/php-sets) [trivial example](https://john.allsup.co/set.php) ```php union($b); $anb = $a->intersect($b); $a_b = $a->difference($b); $b_a = $b->difference($a); $axb = $a->symmetricDifference($b); ``` to construct from an array, we need to use ReflectionClass: ```php union($set_reflector->newInstanceArgs([10,11,12])); var_dump($x); # for convenience function newset($elements) { $set_reflector = new ReflectionClass("PhpSets\Set"); return $set_reflector->newInstanceArgs($elements); } # and then we can do $x = $a->union(newset([10,11,12])); var_dump($x); ```