从stdClass中提取值

时间:2014-12-25 07:49:54

标签: php import.io

我有这组值,我如何使用PHP来提取数组?我试过echo result [0];或结果[0] - >标题;不起作用:(

object(stdClass)#1 (6) { 
    ["offset"]=> int(0) 
    ["results"]=> array(16) { 
        [0]=> object(stdClass)#2 (10) { 
            ["image"]=> string(61) "http://ecx.images-amazon.com/images/I/513e74vbkBL._AA160_.jpg" 
            ["price_range/_text"]=> string(14) "$6.99 - $23.55" 
            ["price_range"]=> string(161) "http://www.amazon.com/Sinland-Absorbent-Travel-Sports-Microfiber/dp/B00C82RXQM/ref=sr_1_1/175-6400296-2709943?ie=UTF8&qid=1419493024&sr=8-1&keywords=sports+towel" 
            ["image/_alt"]=> string(15) "Product Details" 
            ["title"]=> string(161) "http://www.amazon.com/Sinland-Absorbent-Travel-Sports-Microfiber/dp/B00C82RXQM/ref=sr_1_1/175-6400296-2709943?ie=UTF8&qid=1419493024&sr=8-1&keywords=sports+towel" 
            ["reviews/_source"]=> string(3) "173" 
            ["title/_title"]=> string(112) "Sinland Ultra Absorbent Travel Sports Towels Workout Towel Microfiber Towel Bath Towels Gym Towels Drying Towels" 
            ["title/_text"]=> string(115) "Sinland Ultra Absorbent Travel Sports Towels Workout Towel Microfiber Towel Bath Towels Gym Towels Drying Towels..." 
            ["reviews"]=> float(173) 
            ["sold_by"]=> string(7) "Sinland" 
        } 
        [1]=> object(stdClass)#3 (10) { 
            ["image"]=> string(61) "http://ecx.images-amazon.com/images/I/41-H4eV8dvL._AA160_.jpg" 
            ["price_range/_text"]=> string(15) "$13.99 - $20.99" 
            ["price_range"]=> string(160) "http://www.amazon.com/NEW-RatTowels-Microfiber-Sapphire-Emerald/dp/B005HQ7Z8M/ref=sr_1_2/175-6400296-2709943?ie=UTF8&qid=1419493024&sr=8-2&keywords=sports+towel" 
            ["image/_alt"]=> string(15) "Product Details" 
            ["title"]=> string(160) "http://www.amazon.com/NEW-RatTowels-Microfiber-Sapphire-Emerald/dp/B005HQ7Z8M/ref=sr_1_2/175-6400296-2709943?ie=UTF8&qid=1419493024&sr=8-2&keywords=sports+towel" 
            ["reviews/_source"]=> string(3) "284" 
            ["title/_title"]=> string(167) "30% Off - #1 Rated Sport and Travel Towel. SportLite Towels - 100% Microfiber S

1 个答案:

答案 0 :(得分:-2)

将其转换为数组。

print_r((array)yourObject);
相关问题