2017-01-10 9 views
-1

特定の連想配列要素に対してのみデータを取得したい。どうすればこれを達成できますか?ここでsnapdeal json apiからデータを取得する方法特定の連想配列要素

はコードです:

<?php  

$ch = curl_init(); 
$id=647672630230; 
curl_setopt($ch, CURLOPT_URL, "affiliate-feeds.snapdeal.com/feed/product?id=$id"); 
curl_setopt(
    $ch, CURLOPT_HTTPHEADER, 
    array(
     'Snapdeal-Affiliate-Id:133419', 
     'Snapdeal-Token-Id:cf72ba3b7c2f47e3e0b09cd7e8613c', 
     'Accept:application/json' 
    ) 
); 

$response = curl_exec($ch); 
curl_close($ch); 

// work with $response here: 
$result = json_decode($response, TRUE); 


?> 

、それが$resultでこの結果を返します。

{"id":647672630230,"title":"Spacewood Carnival Queen Bed","description":"Non-cancellable: Order can't be cancelled after 48 hours Color : Wenge Ideal Mattress Size (L X B in cm) : Standard mattress size for bed: 150 x 195 cm (Mattress is not included in the sales package) Finish : Melamine Size : Queen Material: Particle Board Overall Height (cm)-80 cm, Overall Width (cm)-163 cm, Overall Depth (cm)-206 cm Queen Size Bed with No Storage Warranty: 12 Months Weight Bearing Capacity: 250 Kgs. Warranty: 36 Months Primary Material: Particle Board Size: Queen Ideal Mattress Size (L X B in cm):150 x 195 cm Finish: Melamine Colour: Wenge Disclaimer: The product colour may slightly vary due to lighting conditions or your monitor settings ","brand":"Spacewood","link":"http://www.snapdeal.com/product/spacewood-carnival-queen-bed/647672630230?utm_source=aff_prog&utm_campaign=afts&offer_id=17&aff_id=133419","imageLink":"http://n1.sdlcdn.com/imgs/b/x/u/Spacewood-Carnival-Queen-Bed-SDL572327220-1-034bf.jpg","subCategoryId":1195,"subCategoryName":"Beds","categoryId":580,"categoryName":"Furniture","mrp":20090,"offerPrice":8299,"effectivePrice":8299,"availability":"in stock","sizes":null,"colors":null,"walletCashback":0} 

しかし、私は唯一のタイトルと説明の詳細をしたいです。どうすれば入手できますか?

答えて

0

あなたは次のようにあなたのアレイにアクセスすることができます:あなたは私のテストを経て、この作業を見ることができます

$result['title']

$result['description']

http://sandbox.onlinephpfunctions.com/code/be2f8f5152e217247a7f82f3a08f699976763995

+0

お知らせ:場合は非オブジェクトのプロパティを取得しようとします私はこれを試してください –

+0

回答@MukeshKumar – Ryan

+0

何も働いていない...(; –

関連する問題