Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8942517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:32:05+00:00 2026-06-15T11:32:05+00:00

After googling a while, I found out I can make google searches using this

  • 0

After googling a while, I found out I can make google searches using this code:

$text=$_GET['text'];
$results=file_get_contents("http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=" . $text);
// Too lazy to use cURL
$results=json_decode($results);

The problem is that $results is actually an object(stdClass), and handling it like I would with arrays doesn’t work (i.e. $results["responseData"]). This is the full var_dump:

object(stdClass)#1 (3) {
  ["responseData"]=>
  object(stdClass)#2 (2) {
    ["results"]=>
    array(4) {
      [0]=>
      object(stdClass)#3 (8) {
        ["GsearchResultClass"]=>
        string(10) "GwebSearch"
        ["unescapedUrl"]=>
        string(51) "http://www.urbandictionary.com/define.php?term=lulz"
        ["url"]=>
        string(55) "http://www.urbandictionary.com/define.php%3Fterm%3Dlulz"
        ["visibleUrl"]=>
        string(23) "www.urbandictionary.com"
        ["cacheUrl"]=>
        string(73) "http://www.google.com/search?q=cache:9eN_paaTATEJ:www.urbandictionary.com"
        ["title"]=>
        string(29) "Urban Dictionary: <b>lulz</b>"
        ["titleNoFormatting"]=>
        string(22) "Urban Dictionary: lulz"
        ["content"]=>
        string(159) "Beginning as a plural variant of lol, <b>Lulz</b> was originally an exclamation but is now   often used as a noun meaning interesting or funny internet cont..."
      }
      [1]=>
      object(stdClass)#4 (8) {
        ["GsearchResultClass"]=>
        string(10) "GwebSearch"
        ["unescapedUrl"]=>
        string(34) "http://en.wiktionary.org/wiki/lulz"
        ["url"]=>
        string(34) "http://en.wiktionary.org/wiki/lulz"
        ["visibleUrl"]=>
        string(17) "en.wiktionary.org"
        ["cacheUrl"]=>
        string(67) "http://www.google.com/search?q=cache:ksdO4S_AefUJ:en.wiktionary.org"
        ["title"]=>
        string(24) "<b>lulz</b> - Wiktionary"
        ["titleNoFormatting"]=>
        string(17) "lulz - Wiktionary"
        ["content"]=>
        string(173) "Like “Hakuna matata†in The Lion King, “<b>lulz</b>†is not just a word, but a philosophy.   [...] Anonymous has made campaigning sexy for the first time since 1968."
      }
      [2]=>
      object(stdClass)#5 (8) {
        ["GsearchResultClass"]=>
        string(10) "GwebSearch"
        ["unescapedUrl"]=>
        string(51) "http://knowyourmeme.com/memes/i-did-it-for-the-lulz"
        ["url"]=>
        string(51) "http://knowyourmeme.com/memes/i-did-it-for-the-lulz"
        ["visibleUrl"]=>
        string(16) "knowyourmeme.com"
        ["cacheUrl"]=>
        string(66) "http://www.google.com/search?q=cache:ITVRlkQkfckJ:knowyourmeme.com"
        ["title"]=>
        string(45) "I Did It for the <b>Lulz</b> | Know Your Meme"
        ["titleNoFormatting"]=>
        string(38) "I Did It for the Lulz | Know Your Meme"
        ["content"]=>
        string(173) "About I Did it for the <b>Lulz</b> (also known as 4 the <b>lulz</b>) is a popular catchphrase used   to express that one carried out a specific action for the sake of perso."
      }
      [3]=>
      object(stdClass)#6 (8) {
        ["GsearchResultClass"]=>
        string(10) "GwebSearch"
        ["unescapedUrl"]=>
        string(56) "http://www.internetslang.com/LULZ-meaning-definition.asp"
        ["url"]=>
        string(56) "http://www.internetslang.com/LULZ-meaning-definition.asp"
        ["visibleUrl"]=>
        string(21) "www.internetslang.com"
        ["cacheUrl"]=>
        string(71) "http://www.google.com/search?q=cache:UNXME3GmS-AJ:www.internetslang.com"
        ["title"]=>
        string(88) "What does <b>LULZ</b> mean? - <b>LULZ</b> Definition - Meaning of <b>LULZ</b> <b>...</b>"
        ["titleNoFormatting"]=>
        string(60) "What does LULZ mean? - LULZ Definition - Meaning of LULZ ..."
        ["content"]=>
        string(185) "This Internet Slang page is designed to explain what the meaning of <b>LULZ</b> is. The   slang word / acronym / abbreviation <b>LULZ</b> means... . Internet Slang. A list of <b>...</b>"
      }
    }
    ["cursor"]=>
    object(stdClass)#7 (6) {
      ["resultCount"]=>
      string(9) "1,080,000"
      ["pages"]=>
      array(8) {
        [0]=>
        object(stdClass)#8 (2) {
          ["start"]=>
          string(1) "0"
          ["label"]=>
          int(1)
        }
        [1]=>
        object(stdClass)#9 (2) {
          ["start"]=>
          string(1) "4"
          ["label"]=>
          int(2)
        }
        [2]=>
        object(stdClass)#10 (2) {
          ["start"]=>
          string(1) "8"
          ["label"]=>
          int(3)
        }
        [3]=>
        object(stdClass)#11 (2) {
          ["start"]=>
          string(2) "12"
          ["label"]=>
          int(4)
        }
        [4]=>
        object(stdClass)#12 (2) {
          ["start"]=>
          string(2) "16"
          ["label"]=>
          int(5)
        }
        [5]=>
        object(stdClass)#13 (2) {
          ["start"]=>
          string(2) "20"
          ["label"]=>
          int(6)
        }
        [6]=>
        object(stdClass)#14 (2) {
          ["start"]=>
          string(2) "24"
          ["label"]=>
          int(7)
        }
        [7]=>
        object(stdClass)#15 (2) {
          ["start"]=>
          string(2) "28"
          ["label"]=>
          int(8)
        }
      }
      ["estimatedResultCount"]=>
      string(7) "1080000"
      ["currentPageIndex"]=>
      int(0)
      ["moreResultsUrl"]=>
      string(76) "http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=lulz"
      ["searchResultTime"]=>
      string(4) "0.23"
    }
  }
  ["responseDetails"]=>
  NULL
  ["responseStatus"]=>
  int(200)
}

So, any clue on how to read the results array? (Didn’t try anything but the $results["responseData"], as I never used JSON before.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:32:06+00:00Added an answer on June 15, 2026 at 11:32 am

    Use the arrow operator to access an object’s data:

    $results->responseData;
    

    Or, if you prefer an array, you can use the 2nd param of json_decode to return the json data as an array, e.g.:

    $results = json_decode($results, true);    
    

    In general, you could also cast any object to an array using this:

    $results = (array) $results;
    

    Using either of the above, you can access your data using PHP array key syntax:

    $results['responseData'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't figure this out, and couldn't find a solution after googling around. I'm
Anyone know what this error means? after googling I found a bunch of sites
I think this is a pretty basic question, but after Googling around I can't
Is this possible? I've spent quite a while googling and found plenty of people
After looking (Googling) on the web for a while, I can find nothing that
While Googling for another bash tip, I found this page on .inputrc http://ss64.com/bash/syntax-inputrc.html ,
From googling around, I found that using while loops or using variables is discouraged.
Here my app deals with phone call.After googling I found the code for calling
Update III: After googling around I've found that this is not an uncommon problem.
After googling and stackoverflowing for a while, I still cannot find anything relevant to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.