主页 M

php解析JSON数据

2020-02-27 网页编程网 网页编程网

json=[ { Name: "沈涛", ReleaseYear: "1984" }, { Name: "The Red Violin", ReleaseYear: "1998" }];

可以这样写$arr = array(0 => array( 'name' => '沈涛', 'ReleaseYear' => '1984'),1 => array('name' => 'The Red Violin', 'ReleaseYear' => '1984' )) 然后再json_encode,然后在页面再用js解析json。

1.data.json

{

"name":”yudabo“,

"score":100

}

2.json.php

$json_string = file_get_contents('json/data.json');

$data = json_decode($json_string, true);

echo $data['name'].' '.$data['score'];

阅读原文
阅读 2207
123 显示电脑版