Jump to content

Extracting Object Content from a Class


natasha_thomas

Recommended Posts

Folks,

 

I need to Extract the Content of "[content] => " Class from the output of the below Script:

 

<?php


$keywords = file_get_contents('http://ajax.googleapis.com/ajax/services/search/web?rsz=large&v=1.0&q="paintball"');
$keywords = json_decode($keywords);
print_r($keywords);



?>

 

 

Output is like:

 

stdClass Object ( [responseData] => stdClass Object ( [results] => Array ( [0] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.paintball.com/ => http://www.paintball.com/ [visibleUrl] => www.paintball.com [cacheUrl] => http://www.google.com/search?q=cache:Zcnr-K8jU4YJ:www.paintball.com [title] => PaintBall.com [titleNoFormatting] => PaintBall.com [content] => Information and meeting place for new and experienced players. Features industry news, equipment reviews, information for new players, links to online ... ) [1] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.zephyrpaintball.com/ => http://www.zephyrpaintball.com/ [visibleUrl] => www.zephyrpaintball.com [cacheUrl] => http://www.google.com/search?q=cache:EkBfV3VsT9UJ:www.zephyrpaintball.com [title] => Cheap Paintball Guns - Cheap Paintball Gear - Cheap Paintball Supplies [titleNoFormatting] => Cheap Paintball Guns - Cheap Paintball Gear - Cheap Paintball Supplies [content] => Cheap Paintball Gear - Zephyr Paintball offers a wide variety of cheap paintball guns as well as cheap paintball supplies that can get you into the painball ... ) [2] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.addictinggames.com/paintballthegame.html => http://www.addictinggames.com/paintballthegame.html [visibleUrl] => www.addictinggames.com [cacheUrl] => http://www.google.com/search?q=cache:TM1GFy3lDIQJ:www.addictinggames.com [title] => Paintball - The Game - Free Puzzle and Board Game from AddictingGames! [titleNoFormatting] => Paintball - The Game - Free Puzzle and Board Game from AddictingGames! [content] => Paintball - The Game, a Free Puzzle and Board Game from AddictingGames: Use your skills to paint a path for the ball to get to the magical square. ) [3] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.paintball-online.com/ => http://www.paintball-online.com/ [visibleUrl] => www.paintball-online.com [cacheUrl] => http://www.google.com/search?q=cache:rm9AvRxLLX4J:www.paintball-online.com [title] => Paintball Guns & Markers at Paintball-Online.com [titleNoFormatting] => Paintball Guns & Markers at Paintball-Online.com [content] => The Internet's largest paintball store featuring over 4000 paintball guns, markers and other gear. Free shipping and 10% off for all VIP members. ) [4] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://en.wikipedia.org/wiki/Paintball => http://en.wikipedia.org/wiki/Paintball [visibleUrl] => en.wikipedia.org [cacheUrl] => http://www.google.com/search?q=cache:h3rpb57aWfcJ:en.wikipedia.org [title] => Paintball - Wikipedia, the free encyclopedia [titleNoFormatting] => Paintball - Wikipedia, the free encyclopedia [content] => Paintball is a sport in which players compete, in teams or individually, to eliminate opponents by hitting them with capsules containing food coloring and ... ) [5] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.ansgear.com/ => http://www.ansgear.com/ [visibleUrl] => www.ansgear.com [cacheUrl] => http://www.google.com/search?q=cache:uiYno-g6MOkJ:www.ansgear.com [title] => Paintball - Cheap Paintball Guns, Gear and Paintball Equipment [titleNoFormatting] => Paintball - Cheap Paintball Guns, Gear and Paintball Equipment [content] => Ansgear has Paintball guns and Paintball equipment for everyone. Get your Paintball equipment for cheap. All Paintball gear on sale! ) [6] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] => http://www.pbreview.com/ => http://www.pbreview.com/ [visibleUrl] => www.pbreview.com [cacheUrl] => http://www.google.com/search?q=cache:OzXP0G1QzFMJ:www.pbreview.com [title] => Paintball Reviews of Guns, Equipment, Games & More | pbreview.com [titleNoFormatting] => Paintball Reviews of Guns, Equipment, Games & More | pbreview.com [content] => All things paintball on pbreview.com. Paintball gun & equipment reviews, paintball videos, a paintball field locator for paintball games & tournaments. ) [7] => stdClass Object ( [GsearchResultClass] => GwebSearch [unescapedUrl] =>

 

 

 

 

 

Desired Output:

 

 

 

How can it be achieved?

 

Cheers

Natasha T

Link to comment
Share on other sites

Object properties are access via ->, this is all covered here.

 

If your still stuck, can you please paste the source of what the call to print_r() produces so it is at least readable?

 

Thrope,

Here is the structures output:

 

stdClass Object

(

    [responseData] => stdClass Object

        (

            [results] => Array

                (

                    [0] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://www.paintball.com/

                            => http://www.paintball.com/

                            [visibleUrl] => www.paintball.com

                            [cacheUrl] => http://www.google.com/search?q=cache:Zcnr-K8jU4YJ:www.paintball.com

                            [title] => PaintBall.com

                            [titleNoFormatting] => PaintBall.com

                            [content] => Information and meeting place for new and experienced players. Features industry  news, equipment reviews, information for new players, links to online ...

                        )

 

                    [1] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://www.zephyrpaintball.com/

                            => http://www.zephyrpaintball.com/

                            [visibleUrl] => www.zephyrpaintball.com

                            [cacheUrl] => http://www.google.com/search?q=cache:EkBfV3VsT9UJ:www.zephyrpaintball.com

                            [title] => Cheap Paintball Guns - Cheap Paintball Gear - Cheap Paintball Supplies

                            [titleNoFormatting] => Cheap Paintball Guns - Cheap Paintball Gear - Cheap Paintball Supplies

                            [content] => Cheap Paintball Gear - Zephyr Paintball offers a wide variety of cheap paintball  guns as well as cheap paintball supplies that can get you into the painball ...

                        )

 

                    [2] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://www.addictinggames.com/paintballthegame.html

                            => http://www.addictinggames.com/paintballthegame.html

                            [visibleUrl] => www.addictinggames.com

                            [cacheUrl] => http://www.google.com/search?q=cache:TM1GFy3lDIQJ:www.addictinggames.com

                            [title] => Paintball - The Game - Free Puzzle and Board Game from AddictingGames!

                            [titleNoFormatting] => Paintball - The Game - Free Puzzle and Board Game from AddictingGames!

                            [content] => Paintball - The Game, a Free Puzzle and Board Game from AddictingGames: Use your  skills to paint a path for the ball to get to the magical square.

                        )

 

                    [3] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://www.paintball-online.com/

                            => http://www.paintball-online.com/

                            [visibleUrl] => www.paintball-online.com

                            [cacheUrl] => http://www.google.com/search?q=cache:rm9AvRxLLX4J:www.paintball-online.com

                            [title] => Paintball Guns & Markers at Paintball-Online.com

                            [titleNoFormatting] => Paintball Guns & Markers at Paintball-Online.com

                            [content] => The Internet's largest paintball store featuring over 4000 paintball guns,  markers and other gear. Free shipping and 10% off for all VIP members.

                        )

 

                    [4] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://en.wikipedia.org/wiki/Paintball

                            => http://en.wikipedia.org/wiki/Paintball

                            [visibleUrl] => en.wikipedia.org

                            [cacheUrl] => http://www.google.com/search?q=cache:h3rpb57aWfcJ:en.wikipedia.org

                            [title] => Paintball - Wikipedia, the free encyclopedia

                            [titleNoFormatting] => Paintball - Wikipedia, the free encyclopedia

                            [content] => Paintball is a sport in which players compete, in teams or individually, to  eliminate opponents by hitting them with capsules containing food coloring and  ...

                        )

 

                    [5] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://www.ansgear.com/

                            => http://www.ansgear.com/

                            [visibleUrl] => www.ansgear.com

                            [cacheUrl] => http://www.google.com/search?q=cache:uiYno-g6MOkJ:www.ansgear.com

                            [title] => Paintball - Cheap Paintball Guns, Gear and Paintball Equipment

                            [titleNoFormatting] => Paintball - Cheap Paintball Guns, Gear and Paintball Equipment

                            [content] => Ansgear has Paintball guns and Paintball equipment for everyone. Get your  Paintball equipment for cheap. All Paintball gear on sale!

                        )

 

                    [6] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://www.pbreview.com/

                            => http://www.pbreview.com/

                            [visibleUrl] => www.pbreview.com

                            [cacheUrl] => http://www.google.com/search?q=cache:OzXP0G1QzFMJ:www.pbreview.com

                            [title] => Paintball Reviews of Guns, Equipment, Games & More | pbreview.com

                            [titleNoFormatting] => Paintball Reviews of Guns, Equipment, Games & More | pbreview.com

                            [content] => All things paintball on pbreview.com. Paintball gun & equipment reviews,  paintball videos, a paintball field locator for paintball games & tournaments.

                        )

 

                    [7] => stdClass Object

                        (

                            [GsearchResultClass] => GwebSearch

                            [unescapedUrl] => http://www.pntball.com/

                            => http://www.pntball.com/

                            [visibleUrl] => www.pntball.com

                            [cacheUrl] => http://www.google.com/search?q=cache:ot8kIpfUIaIJ:www.pntball.com

                            [title] => Paintball Guns Gear - Tippmann BT Empire Spyder Paintball Markers

                            [titleNoFormatting] => Paintball Guns Gear - Tippmann BT Empire Spyder Paintball Markers

                            [content] => Paintball guns store selling Kingman Spyder guns, Empire equipment and paintball  markers. We stock Tippmann X7, A5, 98 custom paintball gun packages, ...

                        )

 

                )

 

            [cursor] => stdClass Object

                (

                    [pages] => Array

                        (

                            [0] => stdClass Object

                                (

                                    [start] => 0

                                    [label] => 1

                                )

 

                            [1] => stdClass Object

                                (

                                    [start] => 8

                                    [label] => 2

                                )

 

                            [2] => stdClass Object

                                (

                                    [start] => 16

                                    [label] => 3

                                )

 

                            [3] => stdClass Object

                                (

                                    [start] => 24

                                    [label] => 4

                                )

 

                            [4] => stdClass Object

                                (

                                    [start] => 32

                                    [label] => 5

                                )

 

                            [5] => stdClass Object

                                (

                                    [start] => 40

                                    [label] => 6

                                )

 

                            [6] => stdClass Object

                                (

                                    [start] => 48

                                    [label] => 7

                                )

 

                            [7] => stdClass Object

                                (

                                    [start] => 56

                                    [label] => 8

                                )

 

                        )

 

                    [estimatedResultCount] => 598000

                    [currentPageIndex] => 0

                    [moreResultsUrl] => http://www.google.com/search?oe=utf8&ie=utf8&source=uds&start=0&hl=en&q=%22paintball%22

                )

 

        )

 

    [responseDetails] =>

    [responseStatus] => 200

)

 

 

 

I need to Extract all "[content] =>  "  in an Array.

 

Cheers

Natasha T

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.