P粉8059312812023-08-14 16:48:10
在循環之前建立一個空的$files
數組,然後像下面這樣在每次循環中合併並返回。
$files = []; $nextPageToken = "empty"; $optParams = array( 'fields' => "nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webView Link,mimeType,parents)", 'pageToken' => $nextPageToken, 'orderBy' => 'modifiedTime desc, name' ); while ( $nextPageToken != null) { $responseFiles = $drive->ListFiles($optParams); $nextPageToken = $responseFiles->getNextPageToken(); $files = array_merge($files, $responseFiles->getFiles()); $optParams['q'] => "'".$match[0]."' in parents"; }
查看array_merge的API文件以取得更多資訊。