title: Handling stdClass objects
body: <p>After googling a while, I found out I can make google searches using this code:</p>
  
  <pre><code>$text=$_GET['text'];
  $results=file_get_contents("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q=" . $text);
  // Too lazy to use cURL
  $results=json_decode($results);
  </code></pre>
  
  <p>The problem is that <code>$results</code> is actually an <code>object(stdClass)</code>, and handling it like I would with arrays doesn't work (i.e. <code>$results["responseData"]</code>). This is the full <code>var_dump</code>:</p>
  
  <pre><code>object(stdClass)#1 (3) {
    ["responseData"]=&gt;
    object(stdClass)#2 (2) {
      ["results"]=&gt;
      array(4) {
        [0]=&gt;
        object(stdClass)#3 (8) {
          ["GsearchResultClass"]=&gt;
          string(10) "GwebSearch"
          ["unescapedUrl"]=&gt;
          string(51) "http://www.urbandictionary.com/define.php?term=lulz"
          ["url"]=&gt;
          string(55) "http://www.urbandictionary.com/define.php%3Fterm%3Dlulz"
          ["visibleUrl"]=&gt;
          string(23) "www.urbandictionary.com"
          ["cacheUrl"]=&gt;
          string(73) "http://www.google.com/search?q=cache:9eN_paaTATEJ:www.urbandictionary.com"
          ["title"]=&gt;
          string(29) "Urban Dictionary: &lt;b&gt;lulz&lt;/b&gt;"
          ["titleNoFormatting"]=&gt;
          string(22) "Urban Dictionary: lulz"
          ["content"]=&gt;
          string(159) "Beginning as a plural variant of lol, &lt;b&gt;Lulz&lt;/b&gt; was originally an exclamation but is now   often used as a noun meaning interesting or funny internet cont..."
        }
        [1]=&gt;
        object(stdClass)#4 (8) {
          ["GsearchResultClass"]=&gt;
          string(10) "GwebSearch"
          ["unescapedUrl"]=&gt;
          string(34) "http://en.wiktionary.org/wiki/lulz"
          ["url"]=&gt;
          string(34) "http://en.wiktionary.org/wiki/lulz"
          ["visibleUrl"]=&gt;
          string(17) "en.wiktionary.org"
          ["cacheUrl"]=&gt;
          string(67) "http://www.google.com/search?q=cache:ksdO4S_AefUJ:en.wiktionary.org"
          ["title"]=&gt;
          string(24) "&lt;b&gt;lulz&lt;/b&gt; - Wiktionary"
          ["titleNoFormatting"]=&gt;
          string(17) "lulz - Wiktionary"
          ["content"]=&gt;
          string(173) "Like â€œHakuna matataâ€ in The Lion King, â€œ&lt;b&gt;lulz&lt;/b&gt;â€ is not just a word, but a philosophy.   [...] Anonymous has made campaigning sexy for the first time since 1968."
        }
        [2]=&gt;
        object(stdClass)#5 (8) {
          ["GsearchResultClass"]=&gt;
          string(10) "GwebSearch"
          ["unescapedUrl"]=&gt;
          string(51) "http://knowyourmeme.com/memes/i-did-it-for-the-lulz"
          ["url"]=&gt;
          string(51) "http://knowyourmeme.com/memes/i-did-it-for-the-lulz"
          ["visibleUrl"]=&gt;
          string(16) "knowyourmeme.com"
          ["cacheUrl"]=&gt;
          string(66) "http://www.google.com/search?q=cache:ITVRlkQkfckJ:knowyourmeme.com"
          ["title"]=&gt;
          string(45) "I Did It for the &lt;b&gt;Lulz&lt;/b&gt; | Know Your Meme"
          ["titleNoFormatting"]=&gt;
          string(38) "I Did It for the Lulz | Know Your Meme"
          ["content"]=&gt;
          string(173) "About I Did it for the &lt;b&gt;Lulz&lt;/b&gt; (also known as 4 the &lt;b&gt;lulz&lt;/b&gt;) is a popular catchphrase used   to express that one carried out a specific action for the sake of perso."
        }
        [3]=&gt;
        object(stdClass)#6 (8) {
          ["GsearchResultClass"]=&gt;
          string(10) "GwebSearch"
          ["unescapedUrl"]=&gt;
          string(56) "http://www.internetslang.com/LULZ-meaning-definition.asp"
          ["url"]=&gt;
          string(56) "http://www.internetslang.com/LULZ-meaning-definition.asp"
          ["visibleUrl"]=&gt;
          string(21) "www.internetslang.com"
          ["cacheUrl"]=&gt;
          string(71) "http://www.google.com/search?q=cache:UNXME3GmS-AJ:www.internetslang.com"
          ["title"]=&gt;
          string(88) "What does &lt;b&gt;LULZ&lt;/b&gt; mean? - &lt;b&gt;LULZ&lt;/b&gt; Definition - Meaning of &lt;b&gt;LULZ&lt;/b&gt; &lt;b&gt;...&lt;/b&gt;"
          ["titleNoFormatting"]=&gt;
          string(60) "What does LULZ mean? - LULZ Definition - Meaning of LULZ ..."
          ["content"]=&gt;
          string(185) "This Internet Slang page is designed to explain what the meaning of &lt;b&gt;LULZ&lt;/b&gt; is. The   slang word / acronym / abbreviation &lt;b&gt;LULZ&lt;/b&gt; means... . Internet Slang. A list of &lt;b&gt;...&lt;/b&gt;"
        }
      }
      ["cursor"]=&gt;
      object(stdClass)#7 (6) {
        ["resultCount"]=&gt;
        string(9) "1,080,000"
        ["pages"]=&gt;
        array(8) {
          [0]=&gt;
          object(stdClass)#8 (2) {
            ["start"]=&gt;
            string(1) "0"
            ["label"]=&gt;
            int(1)
          }
          [1]=&gt;
          object(stdClass)#9 (2) {
            ["start"]=&gt;
            string(1) "4"
            ["label"]=&gt;
            int(2)
          }
          [2]=&gt;
          object(stdClass)#10 (2) {
            ["start"]=&gt;
            string(1) "8"
            ["label"]=&gt;
            int(3)
          }
          [3]=&gt;
          object(stdClass)#11 (2) {
            ["start"]=&gt;
            string(2) "12"
            ["label"]=&gt;
            int(4)
          }
          [4]=&gt;
          object(stdClass)#12 (2) {
            ["start"]=&gt;
            string(2) "16"
            ["label"]=&gt;
            int(5)
          }
          [5]=&gt;
          object(stdClass)#13 (2) {
            ["start"]=&gt;
            string(2) "20"
            ["label"]=&gt;
            int(6)
          }
          [6]=&gt;
          object(stdClass)#14 (2) {
            ["start"]=&gt;
            string(2) "24"
            ["label"]=&gt;
            int(7)
          }
          [7]=&gt;
          object(stdClass)#15 (2) {
            ["start"]=&gt;
            string(2) "28"
            ["label"]=&gt;
            int(8)
          }
        }
        ["estimatedResultCount"]=&gt;
        string(7) "1080000"
        ["currentPageIndex"]=&gt;
        int(0)
        ["moreResultsUrl"]=&gt;
        string(76) "http://www.google.com/search?oe=utf8&amp;ie=utf8&amp;source=uds&amp;start=0&amp;hl=en&amp;q=lulz"
        ["searchResultTime"]=&gt;
        string(4) "0.23"
      }
    }
    ["responseDetails"]=&gt;
    NULL
    ["responseStatus"]=&gt;
    int(200)
  }
  </code></pre>
  
  <p>So, any clue on how to read the results array? (Didn't try anything but the <code>$results["responseData"]</code>, as I never used JSON before.)</p>