1 2 3 4 5 
4 5 6 7 8 
1 2 3 4 5 6 7 8 
4 5 
1 2 3 
6 7 8 
1 2 3 6 7 8 
Source:
<?php
require_once("Set.php"); // from: https://github.com/jakewhiteley/php-sets
$a = new PhpSets\Set(1,2,3,4,5);
$b = new PhpSets\Set(4,5,6,7,8);
$aub = $a->union($b);
$anb = $a->intersect($b);
$a_b = $a->difference($b);
$b_a = $b->difference($a);
$axb = $a->symmetricDifference($b);
echo "<pre>\n";
foreach($a as $x) { echo "$x "; } echo "\n";
foreach($b as $x) { echo "$x "; } echo "\n";
foreach($aub as $x) { echo "$x "; } echo "\n";
foreach($anb as $x) { echo "$x "; } echo "\n";
foreach($a_b as $x) { echo "$x "; } echo "\n";
foreach($b_a as $x) { echo "$x "; } echo "\n";
foreach($axb as $x) { echo "$x "; } echo "\n";
$src = file_get_contents(__FILE__);
$src = str_replace("&","&amp;",$src);
$src = str_replace("<","&lt;",$src);
$src = str_replace(">","&gt;",$src);
echo "Source:\n$src";