处理 ErrorException (E_NOTICE) 未定义的偏移量:0

handling ErrorException (E_NOTICE) Undefined offset: 0

I am trying to access the elements within the text JSON reference from the call, for example, I am trying to access the item (content)

inside the JSON but it continues to show me the error message knowing that the code works and the full text of the JSON file is displayed without problems Is there a similar PHP lavarel method that can be used as an arrylist Or any kind of data structure that is used to obtain the elements within a response

$client = new Client();
$request = $client->post('http://localhost:4567/user/login', [
                'headers' => ['Content-Type' => 'application/json'],
                'body' => json_encode($data),
          ]);
$request= json_decode($request->getBody(), true);
return $request[0];

你的代码应该像

use GuzzleHttp\Client;

$client = new Client();
    $request = $client->post('http://localhost:4567/user/login', [
                'headers' => ['Content-Type' => 'application/json'],
                'body' => json_encode($data),
            ]);
 return $request->getBody();