title: Parsing JSON object in PHP using json_decode(for loops)
body: <pre><code>&lt;?php
  
  $articleurl = 'http://m.tonton.com.my/webservices/article/get?uniqueid=6E619732-9501-4106-860C-  A20D0016E7F0&amp;includeChildTypes=episode&amp;parents=package_season%2Cpackage_content%2Cprogram&amp;c hildren=1&amp;sortBy=published_date&amp;sortDirection=ASC&amp;compact=0&amp;cache=';
  $articlecontent = file_get_contents($articleurl);
  $articlejson = json_decode($articlecontent, true);
  $arr = $articlejson["data"]["children"];
  $max = max(array_keys($arr));
  echo $max; //8 episode
  for ($i=0; $i&lt;=$max;++$i)
  {
      $articleid[$i] = $articlejson['data']['children']['$i']['uniqueId'];
      $mediaid[$i] = $articlejson['data']['children']['$i']['version_viostream_id']['default'];
      $resources[$i] = 'http://m.tonton.com.my/webservices/media/getProgressiveResources?articleid='.$articleid[$i].'&amp;mediaid='.$mediaid[$i].'&amp;token=&amp;cache=&amp;manifestMode=progressive';
      print_r($resources[$i]);
  }
  </code></pre>
  
  <p>I am trying to find all available array keys and insert the available variable into the link, but when I run the code, I get the error:</p>
  
  <blockquote>
    <p>"Undefined index: $i in C:\xampp\htdocs\index.php on line 15 Notice:
    Undefined index: $i in C:\xampp\htdocs\index.php on line 16"</p>
  </blockquote>