从 Guzzle 流中获取项目
Get item from Guzzle stream
我目前有以下代码:
$client = new \GuzzleHttp\Client();
// Get current round ID
$roundRequest = $client->get('https://api-football-v1.p.rapidapi.com/v2/fixtures/rounds/2/current');
$roundResponse = $roundRequest->getBody();
哪个 returns 以下 Guzzle 流:
{"api":{"results":1,"fixtures":["Regular_Season_-_38"]}}
将其更改为我可以轻松获取 'fixtures' 子数组(永远只包含一个值)的值的格式的最佳方法是什么?
$response = json_decode($roundRequest->getBody()->getContents());
我目前有以下代码:
$client = new \GuzzleHttp\Client();
// Get current round ID
$roundRequest = $client->get('https://api-football-v1.p.rapidapi.com/v2/fixtures/rounds/2/current');
$roundResponse = $roundRequest->getBody();
哪个 returns 以下 Guzzle 流:
{"api":{"results":1,"fixtures":["Regular_Season_-_38"]}}
将其更改为我可以轻松获取 'fixtures' 子数组(永远只包含一个值)的值的格式的最佳方法是什么?
$response = json_decode($roundRequest->getBody()->getContents());