我正在嘗試使用以JSON格式輸出結果的API。在JSON的輸出是這樣的:提取JSON數據並嵌入到HTML
"status": "ok",
"registry": {
"id": 110915,
"name": "John",
"enlisted": 1359114500
}
從這個輸出,我想提取name
和使用PHP/HTML打印。這個怎麼做?我嘗試了像iframe
之類的東西,但那不起作用。
我正在嘗試使用以JSON格式輸出結果的API。在JSON的輸出是這樣的:提取JSON數據並嵌入到HTML
"status": "ok",
"registry": {
"id": 110915,
"name": "John",
"enlisted": 1359114500
}
從這個輸出,我想提取name
和使用PHP/HTML打印。這個怎麼做?我嘗試了像iframe
之類的東西,但那不起作用。
,因爲你要使用的PHP:
<?php
// get the json
$data = file_get_contents('http://url_to_the_json');
// decode the json
$data = json_decode($data);
// see it
echo '<pre>' . print_r($data, true) . '</pre>';
// data is now a php object/array/combination.
// I'm not sure how your json file is structured but you can try:
echo $data->registry->name;
registry.name將具有值約翰... –