title: How to read Facebook JSON results in PHP
body: <p>Sorry - this will be a bit poorly worded. </p>
  
  <p>My code <code>fbid</code> is from a form. I what to know how to get and display parts on whats been requested by <code>file_get_contents()</code>.</p>
  
  <pre><code>&lt;?php echo $_POST["fbid"]; ?&gt;
  &lt;?php $x=$_POST['fbid'];?&gt;
  &lt;?php echo file_get_contents("http://graph.facebook.com/" . $x); ?&gt;
  </code></pre>
  
  <p>See the code below that's what the <code>file_get_contents()</code> displays like:</p>
  
  <pre><code>{
    "id": "4",
    "name": "Mark Zuckerberg",
    "first_name": "Mark",
    "last_name": "Zuckerberg",
    "link": "http:\/\/www.facebook.com\/zuck",
    "username": "zuck",
    "gender": "male",
    "locale": "en_US"
  }
  </code></pre>
  
  <p>How can I echo the fields <code>name</code> and <code>gender</code> from this string?</p>
  
  <pre><code>Name: Their name 
  Gender: Their gender
  </code></pre>