天天看点

PHP:读取本地json文件并转换成PHP数组

本地json文件 data.json

{
    "name": "Tom",
    "age": "25"
}      
<?php

$data = json_decode(file_get_contents('./data.json'), true);
print_r($data);

// Array
// (
//     [name] => Tom
//     [age] => 25
// )