我使用Quizlet API 2.0,和我很新的这我将如何读这个阵列(“stdClass的对象”)
我如何读的东西值(一个或多个)是这样的:
stdClass Object ([id] => 102269 [name] => Learn Spanish with Cats! [set_count] => 3 [user_count] => 10 [created_date] => 1308035691 [is_public] => 1 [has_password] => [has_access] => 1 [has_discussion] => 1 [member_add_sets] => 1 [description] => This set is exclusively for Spanish flashcard sets with relevant cat images as the set definitions. [sets] => Array ([0] => stdClass Object ([id] => 6081999 [url] => http://quizlet.com/6081999/lesson-4-with-catsdogs-flash-cards/ [title] => Lesson 4 (with cats+dogs) [created_by] => wsvincent [term_count] => 33 [created_date] => 1311984796 [modified_date] => 1312490710 [has_images] => 1 [subjects] => Array ([0] => spanish cats dogs) [visibility] => public [editable] => groups [has_access] => 1) [1] => stdClass Object ([id] => 5855751 [url] => http://quizlet.com/5855751/paso-a-paso-book-1-chapter-4-flash-cards/ [title] => Paso a Paso Book 1 Chapter 4 [created_by] => catdawg426 [term_count] => 30 [created_date] => 1307761267 [modified_date] => 1307819129 [has_images] => 1 [subjects] => Array ([0] => spanish) [visibility] => public [editable] => only_me [has_access] => 1) [2] => stdClass Object ([id] => 5873819 [url] => http://quizlet.com/5873819/los-gatos-de-viaje-flash-cards/ [title] => Los Gatos de Viaje! [created_by] => tiffreja [term_count] => 21 [created_date] => 1307996657 [modified_date] => 1307996796 [has_images] => 1 [subjects] => Array ([0] => spanish [1] => language [2] => foreign) [visibility] => public [editable] => only_me [has_access] => 1)) [members] => Array ([0] => stdClass Object ([username] => philfreo [role] => creator [email_notification] => 1) [1] => stdClass Object ([username] => milkncookies [role] => member [email_notification] => 1) [2] => stdClass Object ([username] => Icypaw [role] => member [email_notification] =>) [3] => stdClass Object ([username] => luckycat10 [role] => member [email_notification] =>) [4] => stdClass Object ([username] => jeffchan [role] => member [email_notification] =>) [5] => stdClass Object ([username] => catchdave [role] => member [email_notification] => 1) [6] => stdClass Object ([username] => tiffreja [role] => member [email_notification] => 1) [7] => stdClass Object ([username] => catdawg426 [role] => member [email_notification] => 1) [8] => stdClass Object ([username] => ihaque [role] => member [email_notification] => 1) [9] => stdClass Object ([username] => jalenack [role] => member [email_notification] => 1)))
例如,如果我想获得第一组名称,“与猫一起学习西班牙语”,我如何通过变量回显它?
这已经是JSON转换成一个数组,我认为:
$data = json_decode($json);
当您粘贴这样的转储时,请确保您包含换行符。 – 2011-12-14 20:07:16
带有一个参数的`json_decode()`不会将JSON转换为数组。请参阅http://php.net/json_decode – salathe 2011-12-14 20:14:30