snipt

Ctrl+h for KB shortcuts
Notice: Snipt is moving away from free accounts on May 1st, 2014. Read more about the transition here.
#7236

PHP

Union of multiple arrays.

1
2
3
<?php
$union = array_unique(array_merge($arr1, $arr2, $arr3));
?>
https://snipt.net/embed/36772754d0f37643ff135f7117aedb7a/
https://snipt.net/raw/36772754d0f37643ff135f7117aedb7a/
36772754d0f37643ff135f7117aedb7a
php
PHP
3
2014-04-24T09:20:15
True
False
/api/public/snipt/7236/
union-of-multiple-arrays
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?php</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">$union</span> <span class="o">=</span> <span class="nb">array_unique</span><span class="p">(</span><span class="nb">array_merge</span><span class="p">(</span><span class="nv">$arr1</span><span class="p">,</span> <span class="nv">$arr2</span><span class="p">,</span> <span class="nv">$arr3</span><span class="p">));</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
array, array_merge, array_unique, php, union