1
我有一个API,我从中检索统计信息并需要解析某些信息以在视图中返回。从Laravel的API返回消息解析一个值PHP
我已经写了一个curl请求来获取我需要从API中获取的信息。
// create curl resource
$ch = curl_init($cdnifybandwidthurl);
// sets GET
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); // -X
// $output contains the output string
$bandwidth_usage = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
该请求将返回这样
{"resource":"xxxx","datefrom":"2015-07-01",
"dateto":"2015-07-31","origin":"xxx.s3-website-us-east-1.amazonaws.com",
"overall_usage":[[{"timestamp":"2015-07-02
00:00:00","cached":1739969,"non_cached":340826,"hits":76}]]}
我需要做的是返回视图中的non_cached量的字符串。我无法从字符串中提取这一数量。
你是对的,但在overall_usage我怎么访问non_cached值,并在视图退回呢? – TheDizzle
@TheDizzle检查我的编辑是否有帮助 – enpenax