如何以JSON格式加载外部托管数据

Baa*_*dow 5 php

拉动外部数据源的语法是什么,外部数据源将JSON格式的数据转换为要使用的变量.我理解使用json_decode($ variable)但是如何将实际数据加载到该变量中进行解码?

met*_*ode 7

如果在外部你的意思是它托管在第三方域名上,那么你打开一个套接字并获取数据:

$variable = file_get_contents('http://example.com/data.json');
$decoded = json_decode($variable);
Run Code Online (Sandbox Code Playgroud)