合併使用Google Drive NextPageToken所建立的陣列為一個陣列
P粉872101673
P粉872101673 2023-08-13 20:28:17
0
1
337
<p>我有以下程式碼,用於從Google Drive下載文件,文件數量由nextPageToken確定,如下所示的程式碼。 </p> <p>程式碼將繼續將陣列加入$files陣列中,直到nextPageToken為null。此時,我有一個未知數量的子數組,我希望將它們合併成一個單獨的數組,而無需循環遍歷所有返回的數組 - 有沒有一種簡單的方法可以使用PHP實現這個目標? </p> <p>所以,在下面的程式碼中,我希望$files[]是一個單一的陣列。例如:</p> <p><code>$result = array_merge($files); </code>只會產生相同的結果</p> <pre class="brush:php;toolbar:false;">``` $nextPageToken = "empty" ; while ( $nextPageToken != null) { $responseFiles = $drive->ListFiles( $optParams); $nextPageToken = $responseFiles->getNextPageToken(); $files[] = $responseFiles->getFiles(); $optParams = array( 'fields' => "nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webView Link,mimeType,parents)", 'q' => "'".$match[0]."' in parents", 'pageToken' => $nextPageToken, 'orderBy' => 'modifiedTime desc, name' ); } ```</pre></p>
P粉872101673
P粉872101673

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!