PHP中的JSON解码数组

时间:2014-10-21 10:48:57

标签: php json

在Url通话中我得到了这种类型的数据。我想得到" coupon_title"价值

Array ( [success] => 1 
[data] => Array ( 
[0] => Array ( 
[0] => Array ( [featured] => [exclusive] => [promo_id] => P11757 
           [offer_id] => 412 [offer_name] => Flipkart.com CPS - India 
           [coupon_title] => Buy Sony Mobiles along with battery charger and get 20% OFF on battery charger 
           [coupon_type] => Promotion 
           [link] => http://tracking.vcommission.com/aff_c?offer_id=412&aff_id=27655&url=http%3A%2F%2Fwww.flipkart.com%2Fpromotion%2Fpr%3Foffer%3DMobile_combo_31.g1%26sid%3Dtyy%2C4io%26 
           [coupon_expiry] => 2015-12-31 [added] => 2014-08-26 ) 

3 个答案:

答案 0 :(得分:0)

$coupon_title = $data['data'][0][0]['coupon_title'];

答案 1 :(得分:0)

必须是

之类的东西
$array['data']['0']['0']['coupon_title']

我没有测试,但它会像它一样。

干杯!

答案 2 :(得分:0)

将您的数组传递为$ mainArray

 $res = array();
    array_walk_recursive($mainArray, function($item,$key){
               global $res;
               $res[$key] = $item;
    });
    echo "<pre>".print_r($res)."</pre>";
    echo $res["coupon_title"];