خرید بک لینک

Vote count: 0

I have a JSON object that converted into php array. how can I get the specific value , let me say, 'man Cause' object. I write some code but this retus both category. thanks in advanced. //this is JSON objec

{
    "success":"true",
    "results":{
                  "3":{
                          "name":"wa",
                          "id"  :"3",
                          "has_child":{
                                        "name":"natural Cause",
                                        "id"  :"300000",
                                        "has_child":{
                                                        "name":"earthquake",
                                                        "id"  :"300001",
                                                        "has_child":{}
                                                    },
                                                    {
                                                        "name":"Flood",
                                                        "id"  :"300002",
                                                        "has_child":{}
                                                    }
                                      },
                                      {
                                          "name":"Human Cause",
                                          "id"  :"400000",
                                          "has_child":{
                                                        "name":"pickpocket",
                                                        "id"  " 400001",
                                                        "has_child":{}
                                                      }
                                      }
                      }
              }
}
<?php
        $category=json_decode(/*json string*/);
        foreach ($category['results'][3]['has_child'] as $key => $waing){
                            foreach($waing['has_child'] as $sub=>$cat){
                            echo '<option value="'.$cat['id'].'">'. $cat['name'].'</option>';
 ?>

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 10 فروردين 1395 ساعت: 21:20

صفحه بندی