title: PHP loop to retrieve each instance of a specific piece of data from within decoded JSON
body: <p>I'm trying to write a loop that will list all the <code>uid</code> in the JSON data. The <code>uid</code> spans two categories (shirts and pants). Below is what I have so far. Any help is greatly appreciated. </p>
  
  <p><strong>Current Code and JSON</strong></p>
  
  <pre><code>$url = 'http://foothillertech.com/student/webdesign/2018/2018benrud2/projects/retail/data2.json';
  $jsonData = file_get_contents($url);
  $data = json_decode($jsonData, true);
  </code></pre>
  
  <p>I can get each <code>uid</code> manually with this - <code>$data['shirts'][0]['uid']</code>, but I'm looking for a way to loop through the data to return all uid's from both the shirts and pants category. </p>
  
  <p>Thank you!</p>
  
  <p><strong>This is the code that solved my problem.</strong> </p>
  
  <p>Thank you @Don't Panic for your help! </p>
  
  <pre><code>foreach ($data as $item_type =&gt; $items) {
      foreach ($items as $item) {
          $uids[] = $item['uid'];
          echo $uids[$i]."&lt;br&gt;";
          $i++;
      }
  }
  </code></pre>