title: PHP merging two arrays by Numeric Value
body: <p>I have two arrays.</p>
  
  <p><strong>$array1</strong> : </p>
  
  <pre><code>Array (
    [0] =&gt; Array (
        [time] =&gt; 100
        [text] =&gt; Hello
    )
    [1] =&gt; Array (
        [time] =&gt; 200
        [text] =&gt; World!
    )
    [3] =&gt; Array (
        [time] =&gt; 300
        [text] =&gt; Array1's There
    )
  )
  </code></pre>
  
  <p>and more...</p>
  
  <p><strong>$array2</strong> : </p>
  
  <pre><code>Array (
    [0] =&gt; Array (
        [time] =&gt; 50
        [text] =&gt; Hello
    )
    [1] =&gt; Array (
        [time] =&gt; 150
        [text] =&gt; World!
    )
    [3] =&gt; Array (
        [time] =&gt; 300
        [text] =&gt; Array2's There
    )
  )
  </code></pre>
  
  <p>and more ...</p>
  
  <p><strong>$desiredResult :</strong></p>
  
  <pre><code>Array (
    [0] =&gt; Array (
        [time] =&gt; 50
        [text] =&gt; Hello
    )
    [1] =&gt; Array (
        [time] =&gt; 100
        [text] =&gt; Hello
    )
    [2] =&gt; Array (
        [time] =&gt; 150
        [text] =&gt; World
    )
    [3] =&gt; Array (
        [time] =&gt; 200
        [text] =&gt; World
    )
    [4] =&gt; Array (
        [time] =&gt; 300
        [text] =&gt; Array1's There
    )
    [5] =&gt; Array (
        [time] =&gt; 300
        [text] =&gt; Array2's There
    )
  )
  </code></pre>
  
  <p>I need to merge two array by time's numeric value, and if time's value the same, Array1's data first.</p>