How to resolve the error "TypeError: implode(): Argument..." when working with Google Sheets API

A note on how to resolve a PHP error encountered while working with the Google Sheets API.
The error message was as follows:
Fatal error: Uncaught TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in /root/vendor/google/apiclient/src/Google/Service/Resource.php:291 (以下略)
Anyway, it seems there's an issue on line 291 of /vendor/google/apiclient/src/Google/Service/Resource.php, so let's take a look.
Line 291 was:
$requestUrl .= '?' . implode($queryVars, '&');
It worked after changing it like this:
$requestUrl .= '?' . implode('&', $queryVars);
implode() correctly takes the delimiter as its first argument.




If this was helpful, we appreciate your support!
Your support will be used for childcare.
Or support by buying something from the buttons below
(You don't have to buy the linked product.)
Amazon
楽天市場
Yahoo!ショッピング
PR