title: Reddit json and PHP - opening foreach() and getting values
body: <p>I am trying to read a reddit json using my account as an example.</p>
  
  <p>Tried the solution above as:</p>
  
  <pre><code>$string_reddit = file_get_contents("https://www.reddit.com/user/joshfolgado/about.json");
  
  $json = json_decode($string_reddit, true);  
  
  $children = $json['data'];
  foreach ($children as $child){
  
  $linkkarma = $child['data']['link_karma'];
  
  }
  </code></pre>
  
  <p>Also tried:</p>
  
  <pre><code>foreach ($json-&gt;data as $mydata){
  
  $values["Latest_Karma"] = $mydata['link_karma'];
  
  }
  </code></pre>
  
  <p>Also tried:</p>
  
  <pre><code>$opts = array(
  'http'=&gt;array(
  'method'=&gt;"GET",
  'header'=&gt;"User-Agent: reddiant api script\r\n"
  ));
  
  $context = stream_context_create($opts);
  $url = "http://www.reddit.com/user/joshfolgado/about.json";
  $json = file_get_contents($url, false, $context);
  
  $result = json_decode($json, true);
  
  foreach ($result as $child){
      $values['Latest_Karma'] = $child['data']['link_karma'];
  }
  </code></pre>
  
  <p>Spent a couple of hours trying do get the values for any of the items inside the "data" array, havent been able to get any.</p>
  
  <p>What am I doing wrong? What am I missing?</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks</p>