title: How to retrieve JSON array value to PHP?
body: <p>I am having a hard time getting the value of an array in JSON to php.</p>
  
  <p>Here is the JSON format I'm trying to retrieve:</p>
  
  <pre><code>{
   "products": [
    {
     "product_id": 18647,
     "model_code": "CVADA-M702-Black-2GEN"
    }
    {
     "product_id": 14343,
     "model_code": "CDEP-Q123-Blue-3GEN"
    }
   ]
  }
  </code></pre>
  
  <p>and I'm trying to retrieve it like this but to no avail:</p>
  
  <pre><code>$response = json_decode($json_response, true);
          foreach($response as $res)
          {
              print $res-&gt;products-&gt;product_id;
          }
  </code></pre>
  
  <p>It works though if I'm only trying to input a singl output:</p>
  
  <pre><code>$response = json_decode($json_response, true);
  print $response['products'][0]['product_id'];
  </code></pre>
  
  <p>So, can anyone help me how to properly retrieve JSON value to php?</p>