Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>&lt;? $my_array = array(0 =&gt; 1, 1 =&gt; 2, 2 =&gt; 3, 3 =&gt; 4, 4 =&gt; 5); $your_array = array(0 =&gt; 1, 1 =&gt; 2); $the_array = array_unique(array_merge($my_array, $your_array)); $_SESSION['test'] = $the_array; print_r($the_array); echo(count($_SESSION['test'])); ?&gt; </code></pre> <p>yields:</p> <p>Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 ) 5</p> <pre><code>&lt;? $my_array = array(0 =&gt; 1, 1 =&gt; 1, 2 =&gt; 1, 3 =&gt; 1, 4 =&gt; 1); $your_array = array(0 =&gt; 1, 1 =&gt; 1); $the_array = array_unique(array_merge($my_array, $your_array)); $_SESSION['test'] = $the_array; print_r($the_array); echo(count($_SESSION['test'])); ?&gt; </code></pre> <p>yields:</p> <p>Array ( [0] => 1 ) 1</p> <p>my guess would be your stdClass Object([id] => xxxxx) are all the same...</p> <p>EDIT</p> <p>another test:</p> <pre><code>&lt;? $my_array = array(0 =&gt; array('id' =&gt; 11), 1 =&gt; array('id' =&gt; 22), 2 =&gt; array('id' =&gt; 22), 3 =&gt; array('id' =&gt; 33), 4 =&gt; array('id' =&gt; 445)); $your_array = array(0 =&gt; array('id' =&gt; 11), 1 =&gt; array('id' =&gt; 7908)); $the_array = array_unique(array_merge($my_array, $your_array), SORT_REGULAR); $_SESSION['test'] = $the_array; print_r($the_array); echo(count($_SESSION['test'])); ?&gt; </code></pre> <p>yields:</p> <p>Array ( [0] => Array ( [id] => 11 ) [1] => Array ( [id] => 22 ) [3] => Array ( [id] => 33 ) [4] => Array ( [id] => 445 ) [6] => Array ( [id] => 7908 ) ) 5</p> <p>I think this is what you're looking for.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload