天天看點

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
// )