2009-10-05 3 views
2

저는 중급 PHP 프로그래머이지만 Google AJAX API의 출력에 어려움을 겪고 있습니다. 나는 stdClassstdClass 구문 분석 PHP의 객체 데이터

stdClass Object ( 
    [responseData] => stdClass Object ( 
     [results] => Array ( 
      [0] => stdClass Object ( 
       [GsearchResultClass] => GwebSearch 
       [unescapedUrl] => http://www.1860-1960.com/shoes.html 
       [url] => http://www.1860-1960.com/shoes.html 
       [visibleUrl] => www.1860-1960.com 
       [cacheUrl] => http://www.google.com/search?q=cache:4bB2OicXg5EJ:www.1860-1960.com 
       [title] => Beautiful Antique Shoes and Boots, Vintage Fashions   [titleNoFormatting] => Beautiful Antique Shoes and Boots, Vintage Fashions 
       [content] => Victorian White Kid Child's Straight Sole Shoes c1850. Victorian Child's Needlepoint Bunny ... Lovely Vintage Shoes. Antique shoes or antique boots. ... 
      ) 
      [1] => stdClass Object ([GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.reproduction-vintage-shoes.com/ [url] => http://www.reproduction-vintage-shoes.com/ [visibleUrl] => www.reproduction-vintage-shoes.com [cacheUrl] => http://www.google.com/search?q=cache:ZIF1MW0oHlwJ:www.reproduction-vintage-shoes.com [title] => Reproduction Vintage Shoes, Affordable, Custom Made, Antique Footwear [titleNoFormatting] => Reproduction Vintage Shoes, Affordable, Custom Made, Antique Footwear [content] => Individually custom made reproduction Victorian and Edwardian shoes and boots. Historically accurate in appearance and made by a dance shoe maker; ... ) 
      [2] => stdClass Object ([GsearchResultClass] => GwebSearch [unescapedUrl] => http://fineartamerica.com/featured/mv--antique-shoes-nancy-ferrier.html [url] => http://fineartamerica.com/featured/mv--antique-shoes-nancy-ferrier.html [visibleUrl] => fineartamerica.com [cacheUrl] => http://www.google.com/search?q=cache:F3D-ay-THp4J:fineartamerica.com [title] => MV - Antique Shoes Photograph by Nancy Ferrier - MV - Antique ... [titleNoFormatting] => MV - Antique Shoes Photograph by Nancy Ferrier - MV - Antique ... [content] => Aug 24, 2009 ... MV - Antique Shoes Photograph by Nancy Ferrier, MV - Antique Shoes Photograph, MV - Antique Shoes Photograph for Sale, MV - Antique Shoes ... ) 
      [3] => stdClass Object ([GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.bobbydene.com/ [url] => http://www.bobbydene.com/ [visibleUrl] => www.bobbydene.com [cacheUrl] => http://www.google.com/search?q=cache:mHJnlzmDYf4J:www.bobbydene.com [title] => BobbyDene's Vintage Clothing, Victorian, Edwardian, Vintage ... [titleNoFormatting] => BobbyDene's Vintage Clothing, Victorian, Edwardian, Vintage ... [content] => Victorian, Edwardian, 1920, 1940, vintage clothing, vintage dresses, antique clothes, hats, shoes, boots, jewelry, and collectables.)) 
     [cursor] => stdClass Object ( 
      [pages] => Array ( 
       [0] => stdClass Object ([start] => 0 [label] => 1) 
       [1] => stdClass Object ([start] => 4 [label] => 2) 
       [2] => stdClass Object ([start] => 8 [label] => 3) 
       [3] => stdClass Object ([start] => 12 [label] => 4) 
       [4] => stdClass Object ([start] => 16 [label] => 5) 
       [5] => stdClass Object ([start] => 20 [label] => 6) 
       [6] => stdClass Object ([start] => 24 [label] => 7) 
       [7] => stdClass Object ([start] => 28 [label] => 8) 
      ) 
     [estimatedResultCount] => 4370000 
     [currentPageIndex] => 0 
     [moreResultsUrl] => http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=antique+shoes 
     ) 
    ) 
    [responseDetails] => 
    [responseStatus] => 200 
) 

나는 그것에서 필요한 모든 출력에 [estimatedResultCount]의 번호 (4370000)하지만, 아무리 내가 그것을 시도하는 방법에는 여러 가지, 내가 할 수없는 해요로 변환 다음 한 올바르게 구문 분석하십시오.

답변

9
$obj->responseData->cursor->estimatedResultCount 
+1

감사합니다. 이제는 멍청한 느낌이 들었습니다. 공백이있는 항목이있을 경우를 대비하여 – user184622

+4

을 입력하십시오.'$ obj -> { '이 키에는 공백이 있습니다.'}' – ina

+0

@ina - 당신은 생명의 은인입니다. –