本篇文章给大家分享的是有关利用php怎么获取json数据中的所有节点路径,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
10年积累的网站制作、做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站设计后付款的网站建设流程,更有浚县免费网站建设让你可以放心的选择与我们合作。$value) { $queue[] = $field; } $head = 0; $tail = count($queue); while ($head < $tail) { $field = $queue[$head++]; $path = explode("/", $field); $tmpData = &$data; foreach ($path as $key => $ph) { $tmpData = &$tmpData[$ph]; } if (is_array($tmpData) && !empty($tmpData)) { $newField = $field; foreach ($tmpData as $curField => $curValue) { $newField = $field . '/' . $curField; $queue[$tail++] = $newField; } } else { $retData[] = $field; } } } return $retData; } //测试数据 $data = file_get_contents("http://restapi.ele.me/v1/restaurants?extras%5B%5D=food_activity&extras%5B%5D=restaurant_activity&extras%5B%5D=certification&fields%5B%5D=id&fields%5B%5D=name&fiel ds%5B%5D=phone&fields%5B%5D=promotion_info&fields%5B%5D=name_for_url&fields%5B%5D=flavors&fields%5B%5D=is_time_ensure&fields%5B%5D=is_premium&fields%5B%5D=image_path&fields%5B%5D=rating&fie lds%5B%5D=is_free_delivery&fields%5B%5D=minimum_order_amount&fields%5B%5D=order_lead_time&fields%5B%5D=is_support_invoice&fields%5B%5D=is_new&fields%5B%5D=is_third_party_delivery&fields%5B% 5D=is_in_book_time&fields%5B%5D=rating_count&fields%5B%5D=address&fields%5B%5D=month_sales&fields%5B%5D=delivery_fee&fields%5B%5D=minimum_free_delivery_amount&fields%5B%5D=minimum_order_des cription&fields%5B%5D=minimum_invoice_amount&fields%5B%5D=opening_hours&fields%5B%5D=is_online_payment&fields%5B%5D=status&fields%5B%5D=supports&fields%5B%5D=in_delivery_area&geohash=wx4g07 j0w1v7&is_premium=0&limit=1000&offset=24&type=geohash"); $ret = iterTree($data); print_r($ret);
以上就是利用php怎么获取json数据中的所有节点路径,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。