note 52947 deleted from function.array-intersect by cmb

From: Date: Sun, 09 Feb 2020 08:27:48 +0000
Subject: note 52947 deleted from function.array-intersect by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-214065@lists.php.net to get a copy of this message
Note Submitter: SETS INTERSECTION ---- $a = array(1,2,3,4,5,2,6,1); /* repeated elements --> $a is not a set */ $b = array(0,2,4,6,8,5,7,9,2,1); /* repeated elements --> $b is not a set */ $ua = array_merge(array_unique($a)); /* now, $a is a set */ $ub = array_merge(array_unique($b)); /* now, $b is a set */ $intersect = array_merge(array_intersect($ua,$ub)); Note: 'array_merge' removes blank spaces in the arrays. Note: order doesn't matter. In one line: $intersect_a_b = array_merge(array_intersect(array_merge(array_unique($a)), array_merge(array_unique($b)))); Additions/corrections wellcome... gRiNgO

« previous php.notes (#214065) next »