ホームページ >バックエンド開発 >PHPチュートリアル >このJSONデータを解析する方法

このJSONデータを解析する方法

WBOY
WBOYオリジナル
2016-06-23 14:01:19978ブラウズ

{"heade":["站次","站名","到时","发时","停留","里程","二等座","一等座","特等座"],"item":[["1","济南西","-","07:05","-","-","-","-","-"],["2","泰安","07:23","07:24","1分","59公里","19.5元","29.5元","-"],["3","曲阜东","07:46","07:53","7分","129公里","39.5元","64.5元","-"],["4","滕州东","08:11","08:13","2分","185公里","54.5元","89.5元","-"],["5","枣庄","08:26","08:28","2分","221公里","69.5元","109.5元","-"],["6","徐州东","08:48","08:50","2分","286公里","89.5元","139.5元","-"],["7","蚌埠南","09:32","09:34","2分","442公里","134元","219元","-"],["8","南京南","10:22","10:24","2分","617公里","189元","304元","-"],["9","镇江南","10:44","10:46","2分","682公里","209元","334元","-"],["10","丹阳北","10:57","10:59","2分","714公里","219元","354元","-"],["11","常州北","11:12","11:14","2分","747公里","229元","369元","-"],["12","无锡东","11:32","11:43","11分","804公里","249元","399元","-"],["13","苏州北","11:54","11:56","2分","831公里","254元","409元","-"],["14","昆山南","12:08","12:10","2分","862公里","263.5元","423.5元","-"],["15","上海虹桥","12:27","-","-","912公里","278.5元","448.5元","-"]],"title":"<B>区间里程:912公里  区间时间:5小时22分</B>"}

この JSON データを解析してヘッダー、項目、タイトルを取得する方法


ディスカッションへの返信 (解決策)

{"heade":["駅番号","駅名","いつ" , "出発時刻","滞在","走行距離","二等席","一等席","特等席"],"item":[["1","済南西"," -", "07:05","-","-","-","-","-"],["2","大安","07:23","07:24" ,"1ポイント","59キロ","19.5元","29.5元","-"],["3","曲符東","07:46","07:53","7ポイント", "129 キロメートル","39.5 元","64.5 元","-"],["4","滕州東","08:11","08:13","2 ポイント", "185キロ","54.5元","89.5元","-"],["5","棗荘","08:26","08:28","2ポイント","221キロ" ,"69.5元","109.5元","-"],["6","徐州東","08:48","08:50","2ポイント","286キロ","89.5元", "139.5 元","-"],["7","蚌埠南","09:32","09:34","2 ポイント","442 キロメートル","134 元", "219元 ","-"],["8","南京南","10:22","10:24","2ポイント","617キロ","189元","304元"," -"],["9","鎮江南","10:44","10:46","2分","682キロ","209元","334元"," -"] ,["10","丹陽北","10:57","10:59","2分","714キロ","219元","354元","-"] ,[" 11","常州北","11:12","11:14","2ポイント","747キロ","229元","369元","-"],[" 12", "無錫東","11:32","11:43","11分","804キロ","249元","399元","-"],["13", "蘇州北","11:54","11:56","2ポイント","831キロ","254元","409元","-"],["14","昆山南" "," 12:08","12:10","2 ポイント","862 キロ","263.5 元","423.5 元","-"],["15","上海虹橋"," 12:27 ","-","-","912km","278.5元","448.5元","-"]],"title":"区間走行距離:912km 区間時間: 5 時間 22 ポイント41908b66e4bc50a75b443e0dfafd01f9"}

rree

$json = '{"heade":["站次","站名","到时","发时","停留","里程","二等座","一等座","特等座"],"item":[["1","济南西","-","07:05","-","-","-","-","-"],["2","泰安","07:23","07:24","1分","59公里","19.5元","29.5元","-"],["3","曲阜东","07:46","07:53","7分","129公里","39.5元","64.5元","-"],["4","滕州东","08:11","08:13","2分","185公里","54.5元","89.5元","-"],["5","枣庄","08:26","08:28","2分","221公里","69.5元","109.5元","-"],["6","徐州东","08:48","08:50","2分","286公里","89.5元","139.5元","-"],["7","蚌埠南","09:32","09:34","2分","442公里","134元","219元","-"],["8","南京南","10:22","10:24","2分","617公里","189元","304元","-"],["9","镇江南","10:44","10:46","2分","682公里","209元","334元","-"],["10","丹阳北","10:57","10:59","2分","714公里","219元","354元","-"],["11","常州北","11:12","11:14","2分","747公里","229元","369元","-"],["12","无锡东","11:32","11:43","11分","804公里","249元","399元","-"],["13","苏州北","11:54","11:56","2分","831公里","254元","409元","-"],["14","昆山南","12:08","12:10","2分","862公里","263.5元","423.5元","-"],["15","上海虹桥","12:27","-","-","912公里","278.5元","448.5元","-"]],"title":"<B>区间里程:912公里  区间时间:5小时22分</B>"}';$arr = json_decode($json);var_dump($arr->heade);
$s = '{"heade":["站次","站名","到时","发时","停留","里程","二等座","一等座","特等座"],"item":[["1","济南西","-","07:05","-","-","-","-","-"],["2","泰安","07:23","07:24","1分","59公里","19.5元","29.5元","-"],["3","曲阜东","07:46","07:53","7分","129公里","39.5元","64.5元","-"],["4","滕州东","08:11","08:13","2分","185公里","54.5元","89.5元","-"],["5","枣庄","08:26","08:28","2分","221公里","69.5元","109.5元","-"],["6","徐州东","08:48","08:50","2分","286公里","89.5元","139.5元","-"],["7","蚌埠南","09:32","09:34","2分","442公里","134元","219元","-"],["8","南京南","10:22","10:24","2分","617公里","189元","304元","-"],["9","镇江南","10:44","10:46","2分","682公里","209元","334元","-"],["10","丹阳北","10:57","10:59","2分","714公里","219元","354元","-"],["11","常州北","11:12","11:14","2分","747公里","229元","369元","-"],["12","无锡东","11:32","11:43","11分","804公里","249元","399元","-"],["13","苏州北","11:54","11:56","2分","831公里","254元","409元","-"],["14","昆山南","12:08","12:10","2分","862公里","263.5元","423.5元","-"],["15","上海虹桥","12:27","-","-","912公里","278.5元","448.5元","-"]],"title":"<B>区间里程:912公里  区间时间:5小时22分</B>"}';if(mb_check_encoding($s, 'gbk')) $s = mb_convert_encoding($s, 'utf-8', 'gbk');print_r(json_decode($s, 1));

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。