title: How to merge two arrays when a key of one of them and a value of the other array is match
body: <p>I am looking for a way to merge two arrays and create two dimension array.</p>
  <p>dayArray</p>
  <pre><code>(
      [1] =&gt; tue
      [2] =&gt; wed
      [4] =&gt; fri
      [5] =&gt; sat
  </code></pre>
  <p>I would like to assign the values below.</p>
  <p>fruitArray</p>
  <pre><code>array (
    'tue' =&gt; 'banana',
    'fri' =&gt; 'apple',
    'sat' =&gt; 'orange',
  )  
  </code></pre>
  <p>two-dimensional array
  expected result</p>
  <pre><code>  $array = [
  　　 1 =&gt;['tue','banana'],
  　　 2 =&gt;['wed'],
  　　 4 =&gt;['fri','apple'],
       5 =&gt;['sat','orange']
  </code></pre>
  <p>I tried to make it</p>
  <pre><code>{
      foreach ($dayArray as $key =&gt; $value)
      {
          if($fruitArray[$value]){
              $dayArray[$key] = array($key,$value,$fruitArray[$value]);
          }
      }
  }
  </code></pre>
  <blockquote>
  <p>ErrorException: Trying to access array offset on value of type null in f</p>
  </blockquote>