<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Creates a new set using values in either the current instance or in another set, but not in both</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ds-set.union.html">Ds\Set::union</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.ds-stack.html">Stack</a></div> <div class="up"><a href="class.ds-set.html">Set</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="ds-set.xor" class="refentry"> <div class="refnamediv"> <h1 class="refname">Ds\Set::xor</h1> <p class="verinfo">(PECL ds >= 1.0.0)</p><p class="refpurpose"><span class="refname">Ds\Set::xor</span> — <span class="dc-title">Creates a new set using values in either the current instance or in another set, but not in both</span></p> </div> <div class="refsect1 description" id="refsect1-ds-set.xor-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><span class="type Ds\Set">Ds\Set</span></span> <span class="methodname"><strong>Ds\Set::xor</strong></span> ( <span class="methodparam"><span class="type"><span class="type Ds\Set">Ds\Set</span></span> <code class="parameter">$set</code></span> )</div> <p class="para rdfs-comment"> Creates a new set containing values in the current instance as well as another <code class="parameter">set</code>, but not in both. </p> <p class="para"> <code class="code">A ⊖ B = {x : x ∈ (A \ B) ∪ (B \ A)}</code> </p> </div> <div class="refsect1 parameters" id="refsect1-ds-set.xor-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <code class="parameter">set</code></dt> <dd> <p class="para"> The other set. </p> </dd> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-ds-set.xor-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> A new set containing values in the current instance as well as another <code class="parameter">set</code>, but not in both. </p> </div> <div class="refsect1 seealso" id="refsect1-ds-set.xor-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="https://en.wikipedia.org/wiki/Symmetric_difference" class="link external">» Symmetric Difference</a> on Wikipedia</li> </ul> </p> </div> <div class="refsect1 examples" id="refsect1-ds-set.xor-examples"> <h3 class="title">Examples</h3> <div class="example" id="example-5332"> <p><strong>Example #1 <span class="function"><strong>Ds\Set::xor()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br />$a </span><span style="color: #007700">= new \</span><span style="color: #0000BB">Ds</span><span style="color: #007700">\</span><span style="color: #0000BB">Set</span><span style="color: #007700">([</span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= new \</span><span style="color: #0000BB">Ds</span><span style="color: #007700">\</span><span style="color: #0000BB">Set</span><span style="color: #007700">([</span><span style="color: #0000BB">3</span><span style="color: #007700">, </span><span style="color: #0000BB">4</span><span style="color: #007700">, </span><span style="color: #0000BB">5</span><span style="color: #007700">]);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">-></span><span style="color: #0000BB">xor</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> <div class="example-contents"><p>The above example will output something similar to:</p></div> <div class="example-contents screen"> <div class="cdata"><pre> object(Ds\Set)#3 (4) { [0]=> int(1) [1]=> int(2) [2]=> int(4) [3]=> int(5) } </pre></div> </div> </div> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="ds-set.union.html">Ds\Set::union</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.ds-stack.html">Stack</a></div> <div class="up"><a href="class.ds-set.html">Set</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>