title: Echo array inside foreach and if isset but only show one data for each value
body: <p>So I have this list of array (I changed the values for privacy purpose);</p>
  
  <pre><code>$datalist  = array(
  1 =&gt; 
  array(
       "12.2.2.2",
       "Netherlands 1",
       "Hub 1",
       "Password",
       "Mfalse"
  ) ,
  array(
      "12.2.2.2",
      "Singapore 1",
      "Hub 2",
      "Password 2",
      "Mfalse"
  ) 
  </code></pre>
  
  <p>And I want the output of array<a href="https://i.stack.imgur.com/AL6ES.png" rel="nofollow noreferrer">2</a> which is the 'Hub' and 'Hub 2'. So I did this php code since I want it to be looped inside a table so all the details will be tabled and organized. But the only thing I need for now is the HUB to be shown.</p>
  
  <pre><code>                foreach ($response-&gt;monitors as $monitors) {
                      if(isset($monitors-&gt;id)){
                        echo
                        '&lt;tr&gt;
                        &lt;td&gt;&lt;i class="fas fa-globe"&gt;&lt;/i&gt; '.$monitors-&gt;friendly_name.'&lt;/td&gt;';
                             foreach ($datalist as $key =&gt; $value) {
                              # code...
                              if (isset($key)) {
                                 echo '&lt;td&gt;'.$value[2].'&lt;/td&gt;';
                              }
                          }
                        echo '&lt;td&gt;'.$monitors-&gt;url.'&lt;/td&gt;
                        &lt;td&gt;'.$monitors-&gt;status.'&lt;/td&gt;
                        &lt;/tr&gt;';
                      }
                    }
  </code></pre>
  
  <p>Since i'm also using other value outputs and the array I wanted is also inside another foreach loop for the table.</p>
  
  <p>So the main problem lies in this part, since whenever I use this, it outputs like this on each loop of the table </p>
  
  <pre><code>foreach ($datalist as $key =&gt; $value) {
                          # code...
                          if (isset($key)) {
                             echo '&lt;td&gt;'.$value[2].'&lt;/td&gt;';
                          }
                      }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Netherlands 1 Hub 1 Hub 2 12.2.2.2 
  Singapore   1 Hub 1 Hub 2 12.2.2.2 
  </code></pre>
  
  <p>But the desired output i'm looking for is;</p>
  
  <pre><code>Netherlands 1 Hub 1 12.2.2.2 
  Singapore   1 Hub 2 12.2.2.2 
  </code></pre>
  
  <p>What could be wrong in my array statement for foreach?</p>
  
  <p>var_dump of $datalist</p>
  
  <pre><code>array (
  1 =&gt; 
  array (
   0 =&gt; 'x',
   1 =&gt; 'Netherlands 1',
   2 =&gt; 'PeenoiseSync',
   3 =&gt; 'x',
   4 =&gt; 'Mfalse',
  ),
  2 =&gt; 
  array (
   0 =&gt; 'x',
   1 =&gt; 'Singapore 1',
   2 =&gt; 'PeenoiseSync',
   3 =&gt; 'x',
   4 =&gt; 'Mfalse',
  ),
  3 =&gt; 
  array (
   0 =&gt; 'x',
   1 =&gt; 'Singapore 2',
   2 =&gt; 'PeenoiseSync',
   3 =&gt; 'x',
   4 =&gt; 'Mfalse',
  ),
   4 =&gt; 
   array (
    0 =&gt; 'x',
    1 =&gt; 'Singapore 3',
    2 =&gt; 'PeenoiseSync',
    3 =&gt; 'x',
    4 =&gt; 'Mfalse',
   ),
   5 =&gt; 
   array (
    0 =&gt; 'x',
    1 =&gt; 'Singapore 4',
    2 =&gt; 'PeenoiseSync',
    3 =&gt; 'x',
    4 =&gt; 'Mfalse',
   ),
   6 =&gt; 
   array (
    0 =&gt; 'x',
    1 =&gt; 'Singapore 5',
    2 =&gt; 'PeenoiseSync',
    3 =&gt; 'x',
    4 =&gt; 'Mfalse',
   ),
   7 =&gt; 
   array (
    0 =&gt; 'x',
    1 =&gt; 'Singapore 6',
    2 =&gt; 'PeenoiseSync',
    3 =&gt; 'x',
    4 =&gt; 'Mfalse',
   ),
   8 =&gt; 
   array (
    0 =&gt; 'x',
    1 =&gt; 'Singapore 7',
    2 =&gt; 'YTAC',
    3 =&gt; 'x',
    4 =&gt; 'Mfalse',
   ),
  )
  </code></pre>
  
  <p>Updated again: Desired output should be something similar to this;
  <a href="https://i.stack.imgur.com/Z8cjo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z8cjo.png" alt="Desired output"></a></p>
  
  <p>Output i'm getting;
  <a href="https://i.stack.imgur.com/AL6ES.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AL6ES.png" alt="Output i&#39;m getting"></a></p>