我正在使用PHP/Codeigniter並與Google APIs Client Library for PHP一起工作,我試圖從多維數組中輸出一些數據。多維關聯數組輸出
在我的控制器我有;
$client = new Google_Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey("MyKey");
$service = new Google_Service_Books($client);
$data = array(
'title' => 'Library Items',
'gbook' => $service->volumes->listVolumes('0-7515-3831-0')
);
在我鑑於我有;
echo 'Page Title is: ' .$title; // this successfully prints 'Library Items'
echo 'Book Title is: '; // need to output the book title here
echo 'Description is: '; // need to output the book description here
當我print_r($gbook)
在我看來,我看到下面的https://pastebin.com/HM5hds6e
我不知道如何從這個陣列(即title
和isbn
)選擇特定值。任何幫助或提示,將不勝感激!
謝謝
你想獲取一本書或一本書的列表?因爲'$ service-> volumes-> listVolumes('Harry Potter')'返回包含所有匹配'Harry Potter'的卷的* Google_Service_Books_Volumes *對象,因此它不是一個單獨的卷/書。 –
請參閱我的答案中的代碼,看看是否有效。 –