title: PHP - array_merge without considering keys
body: <p>I need help with php array merging</p>
  
  <p>I need merge by values,</p>
  
  <p>so if I have values in array 1 like this </p>
  
  <pre><code> ( room room )  and in array values  ( room ) , merge will look like this =  ( room room ) 
  </code></pre>
  
  <p>But if I have</p>
  
  <pre><code> ( room room book ) and ( book book ) merged array values will look like this  ( room room book book ) 
  </code></pre>
  
  <p>So lets say, merged array values will be maximum count of each element, room for example , in all arrays</p>
  
  <p>Few more examples,
      ( book ) ( book ) ( book ) = ( book ) 
      ( room book book ) ( library room ) = ( library room book book ) 
      ( room room ) ( book book book ) = ( room room book book book ) 
      (room) ( room ) ( room room room ) = ( room room room ) </p>
  
  <p>I tried operator + , but then </p>
  
  <blockquote>
    <p>( room room ) ( book book book ) is ( room room book book ), that is not good</p>
  </blockquote>
  
  <p>I tried array_merge , but then </p>
  
  <blockquote>
    <p>( room ) ( room ) is ( room ) , this is okay
    but 
    ( room room ) ( room ) is ( room room room ) and that is wrong </p>
  </blockquote>
  
  <p>It doesnt depend on order, and keys are not imporant, it is always numeric ( [0] [1] etc. )</p>
  
  <p>ARRAYS :</p>
  
  <pre><code>                [0] =&gt; Array
                      (
                          [0] =&gt; room
                          [1] =&gt; room
                      )
  
                  [1] =&gt; Array
                      (
                          [0] =&gt; book
                          [1] =&gt; book
                          [2] =&gt; book
                          [3] =&gt; book
                      )
  
  EXPECTED RESULT = array ( room, room, book , book , book, book )
  
                  [0] =&gt; Array
                      (
                          [0] =&gt; room
                          [1] =&gt; room
                      )
  
                  [1] =&gt; Array
                      (
                          [0] =&gt; room
                      )
  
  EXPECTED RESULT = array ( room, room )
  
                  [0] =&gt; Array
                      (
                          [0] =&gt; room
                      )
  
                  [1] =&gt; Array
                      (
                          [0] =&gt; room
  
  
                      )
  
  EXPECTED RESULT = array ( room )
  
                  [0] =&gt; Array
                      (
                          [0] =&gt; room
                          [1] =&gt; room
                          [2] =&gt; book
                      )
  
                  [1] =&gt; Array
                      (
                          [0] =&gt; room
                          [1] =&gt; book
                      )
                  [2] =&gt; Array
                      (
                          [0] =&gt; room
                          [1] =&gt; room
                          [2] =&gt; room
                      )
  
  EXPECTED RESULT = array ( room , room ,room , book )
  </code></pre>
  
  <p>So it is alway maximum count of each ellement, for example book in all arrays</p>
  
  <p>Thank you very much,</p>
  
  <p>Marek</p>