title: Looping through JSON using PHP
body: <p>I have the below JSON I need to loop through in PHP.</p>
  <pre><code>    {
   &quot;page&quot;: 1,
   &quot;perPage&quot;: 3,
   &quot;count&quot;: 607,
   &quot;status&quot;: &quot;OK&quot;,
   &quot;tickers&quot;: [
    {
     &quot;ticker&quot;: &quot;A&quot;,
     &quot;name&quot;: &quot;Agilent Technologies Inc.&quot;,
     &quot;market&quot;: &quot;STOCKS&quot;,
     &quot;locale&quot;: &quot;US&quot;,
     &quot;type&quot;: &quot;CS&quot;,
     &quot;currency&quot;: &quot;USD&quot;,
     &quot;active&quot;: true,
     &quot;primaryExch&quot;: &quot;NYE&quot;,
     &quot;updated&quot;: &quot;2020-12-15&quot;,
     &quot;codes&quot;: {
      &quot;cik&quot;: &quot;0001090872&quot;,
      &quot;figiuid&quot;: &quot;EQ0087231700001000&quot;,
      &quot;scfigi&quot;: &quot;BBG001SCTQY4&quot;,
      &quot;cfigi&quot;: &quot;BBG000C2V3D6&quot;,
      &quot;figi&quot;: &quot;BBG000C2V3D6&quot;
     },
     &quot;url&quot;: &quot;&quot;
    },
    {
     &quot;ticker&quot;: &quot;AA&quot;,
     &quot;name&quot;: &quot;Alcoa Corporation&quot;,
     &quot;market&quot;: &quot;STOCKS&quot;,
     &quot;locale&quot;: &quot;US&quot;,
     &quot;type&quot;: &quot;CS&quot;,
     &quot;currency&quot;: &quot;USD&quot;,
     &quot;active&quot;: true,
     &quot;primaryExch&quot;: &quot;NYE&quot;,
     &quot;updated&quot;: &quot;2020-12-15&quot;,
     &quot;codes&quot;: {
      &quot;cik&quot;: &quot;0001675149&quot;,
      &quot;figiuid&quot;: &quot;EQ0000000045469815&quot;,
      &quot;scfigi&quot;: &quot;BBG00B3T3HF1&quot;,
      &quot;cfigi&quot;: &quot;BBG00B3T3HD3&quot;,
      &quot;figi&quot;: &quot;BBG00B3T3HD3&quot;
     },
     &quot;url&quot;: &quot;&quot;
    },
    {
     &quot;ticker&quot;: &quot;WADV&quot;,
     &quot;name&quot;: &quot;Wireless Advantage Inc Common Stock&quot;,
     &quot;market&quot;: &quot;STOCKS&quot;,
     &quot;locale&quot;: &quot;US&quot;,
     &quot;type&quot;: &quot;CS&quot;,
     &quot;currency&quot;: &quot;USD&quot;,
     &quot;active&quot;: true,
     &quot;primaryExch&quot;: &quot;GREY&quot;,
     &quot;updated&quot;: &quot;2020-03-30&quot;,
     &quot;codes&quot;: {
      &quot;figiuid&quot;: &quot;EQ0010295500001000&quot;,
      &quot;scfigi&quot;: &quot;BBG001S87270&quot;,
      &quot;cfigi&quot;: &quot;BBG000DKG4K2&quot;,
      &quot;figi&quot;: &quot;BBG000DKG4K2&quot;
     },
     &quot;url&quot;: &quot;&quot;
    }
   ]
  }
  </code></pre>
  <p>This is my function to loop through - I simply only need the &quot;ticker&quot; from each of the nested arrays.</p>
  <pre><code>public function getTickers()
      {
          $APIKey = &quot;API_KEY&quot;;
                  
          $tickers_request = 'API_URL';
          $session = curl_init($tickers_request);
          curl_setopt($session, CURLOPT_HEADER, true);
          curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
                  
          $response = curl_exec($session);
          curl_close($session);
              
          $json = substr($response, strpos($response, &quot;{&quot;));
              
          $result = json_decode($json, true);
          
          $ticker =[];
          
          foreach($result as $results)  
          {
              foreach ($results['tickers'] as $ticker)
              {
                  $ticker['ticker'] = $results['ticker'];
              }
          }
          return $ticker;
          
      }
  </code></pre>
  <p>I receive these two errors in PHP -</p>
  <pre><code>A PHP Error was encountered
  Severity: Warning
  
  Message: Invalid argument supplied for foreach()
  
  Severity: Notice
  
  Message: Array to string conversion
  </code></pre>
  <p>What's wrong with my function? I'm a seasoned PHP developer but perhaps I am missing something...</p>