如何从数组中获取对象(stdClass) [英] How to get object(stdClass) from array
问题描述
以下问题是获取这个数组的object(stdClass),我该如何获取这些值的all呢?我想要Pcv(校园Aalst)和Mss(Privaatpraktijk kinesitherapie Peeters Stefaan)等等。
array(106){
[0] =>
object(stdClass)#8(45){
[nid] =>
string(3) 199
[type] =>
string(11)stageplaats
[language] =>
string(2)nl
[uid] =>
string(2)33
[status] =>
string(1)1
[创建] =>
string(10)1291279334
[changed] =>
string(10)1301323146
[comment] = >
string(1)0
[促销] =>
string(1)0
[中等] =>
string(1)0
[sticky] =>
string(1)0
[tnid] =>
string 1)0
[translate] =>
string(1)0
[vid] =>
string(3)206
[revision_uid] =>
string(2)16
[title] =>
string (18)Pcv(校园Aalst)
[body] =>
string(0)
[teaser] =>
string(0)
[log] =>
string(0)
[revision_timestamp] =>
string(10)1301323146
[format] =>
string(1)0
[nd_switch_bm] =>
string(0)
[name] =>
string(12)stage.revaki
[picture] =>
string(0)
[data] =>
string(72)a:1:{s:13:form_build_id; s:37:form-f89b99e4a5249b192ff472579b826b00;}
[field_stagedomein_audiologo] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_geneeskunde] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_lo] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_revaki] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(3)152
}
}
[field_stagedomein_verpleeg] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_status] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(14)niet opgegeven
}
}
[field_status_datum] =>
数组(1){
[0] =>
数组(4){
[value] =>
NULL
[timezone] =>
string(15)欧洲/布鲁塞尔
[timezone_db] =>
string(15)欧洲/布鲁塞尔
[date_type] =>
string(4)date
}
}
[field_locatieview] =>
数组(1){
[0] =>
数组(1){
[nid] =>
string(3)179
}
}
[field_status_extra] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_status_stagedomein] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(6)Actief
}
}
[field_maxcapstud_stagedomein] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(2)18
}
}
[field_status_bevestigd_door] =>
数组(1){
[0] =>
数组(1){
[nid] =>
NULL
}
}
[field_aanpers_stageplaats] =>
数组(1){
[0] =>
数组(1){
[nid] =>
NULL
}
}
[field_extrainfo_stagedomein] =>
数组(1){
[0] =>
array(2){
[value] =>
string(37)Capaciteit:3 studenten alle periodes
[format] =>
NULL
}
}
[field_percapaciteit_stageplaats] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_aanplaats_stageplaats] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_mentoren] =>
数组(1){
[0] =>
数组(1){
[nid] =>
string(3)178
}
}
[field_persoon_stagedomein] =>
数组(1){
[0] =>
数组(1){
[nid] =>
NULL
}
}
[has_body] =>
string(1)0
[taxonomy] =>
数组(0){
}
}
[1] =>
object(stdClass)#24(45){
[nid] =>
string(3)211
[type] =>
string(11)stageplaats
[language] =>
string(2)nl
[uid] =>
string(2)33
[status] =>
string(1)1
[created] =>
string(10)1291281467
[changed] =>
string(10)1301323440
[comment] =>
string(1)0
[promotion] =>
string(1)0
[中等] =>
string(1)0
[sticky] =>
string(1)0
[tnid] =>
string(1)0
[translate] =>
string(1)0
[vid] =>
string(3)218
[revision_uid] =>
string(2)16
[title] =>
string(53)Mss(Privaatpraktijk kinesitherapie Walravens Marc)
[body] =>
string(0)
[teaser] =>
string(0)
[log] =>
string(0)
[revision_timestamp] =>
string(10)1301323440
[format] =>
string(1)0
[nd_switch_bm] =>
string(0)
[name] =>
string(12)stage.revaki
[picture] =>
string(0)
[data] =>
string(72)a:1:{s:13:form_build_id; s:37:form-f89b99e4a5249b192ff472579b826b00;}
[field_stagedomein_audiologo] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_geneeskunde] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_lo] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_revaki] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(3)128
}
}
[field_stagedomein_verpleeg] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_status] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(14)niet opgegeven
}
}
[field_status_datum] =>
数组(1){
[0] =>
数组(4){
[value] =>
NULL
[timezone] =>
string(15)欧洲/布鲁塞尔
[timezone_db] =>
string(15)欧洲/布鲁塞尔
[date_type] =>
string(4)date
}
}
[field_locatieview] =>
数组(1){
[0] =>
数组(1){
[nid] =>
string(3)210
}
}
[field_status_extra] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_status_stagedomein] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(6)Actief
}
}
[field_maxcapstud_stagedomein] =>
数组(1){
[0] =>
数组(1){
[value] =>
string(1)4
}
}
[field_status_bevestigd_door] =>
数组(1){
[0] =>
数组(1){
[nid] =>
NULL
}
}
[field_aanpers_stageplaats] =>
数组(1){
[0] =>
数组(1){
[nid] =>
NULL
}
}
[field_extrainfo_stagedomein] =>
数组(1){
[0] =>
array(2){
[value] =>
string(40)Capaciteit:1个学生在periode 3 tem 6
[format] =>
NULL
}
}
[field_percapaciteit_stageplaats] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_aanplaats_stageplaats] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_mentoren] =>
数组(1){
[0] =>
数组(1){
[nid] =>
string(3)208
}
}
[field_persoon_stagedomein] =>
数组(1){
[0] =>
数组(1){
[nid] =>
NULL
}
}
[has_body] =>
string(1)0
[taxonomy] =>
数组(0){
}
}
[2] =>
object(stdClass)#26(45){
[nid] =>
string(3)217
[type] =>
string(11)stageplaats
[language] =>
string(2)nl
[uid] =>
string(2)33
[status] =>
string(1)1
[created] =>
string(10)1291281906
[changed] =>
string(10)1301323440
[comment] =>
string(1)0
[promotion] =>
string(1)0
[中等] =>
string(1)0
[sticky] =>
string(1)0
[tnid] =>
string(1)0
[translate] =>
string(1)0
[vid] =>
string(3)224
[revision_uid] =>
string(2)16
[title] =>
string(54)Mss(Privaatpraktijk kinesitherapie Peeters Stefaan)
[body] =>
string(0)
[teaser] =>
string(0)
[log] =>
string(0)
[revision_timestamp] =>
string(10)1301323440
[format] =>
string(1)0
[nd_switch_bm] =>
string(0)
[name] =>
string(12)stage.revaki
[picture] =>
string(0)
[data] =>
string(72)a:1:{s:13:form_build_id; s:37:form-f89b99e4a5249b192ff472579b826b00;}
[field_stagedomein_audiologo] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_geneeskunde] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
[field_stagedomein_lo] =>
数组(1){
[0] =>
数组(1){
[value] =>
NULL
}
}
该对象位于数组中的索引0处,因此您只需访问属性名称
echo $ theArray [0] - >标题;
没有进攻,但如果你真的要问我强烈建议你紧紧抓住语言通过实际阅读PHP手册的语言参考,特别是
I have the following array. I retrieved this with node_load(), and made it an array of it the reason is to get/manipulate the data. (I'm trying to make a internship assigment webtool for students and internships). The following problem is to get the 'object(stdClass)' of this array, how can I get "all" these values of it? I want the value "Pcv (campus Aalst)" and "Mss ( Privaatpraktijk kinesitherapie Peeters Stefaan )"" and so on.
array(106) {
[0]=>
object(stdClass)#8 (45) {
["nid"]=>
string(3) "199"
["type"]=>
string(11) "stageplaats"
["language"]=>
string(2) "nl"
["uid"]=>
string(2) "33"
["status"]=>
string(1) "1"
["created"]=>
string(10) "1291279334"
["changed"]=>
string(10) "1301323146"
["comment"]=>
string(1) "0"
["promote"]=>
string(1) "0"
["moderate"]=>
string(1) "0"
["sticky"]=>
string(1) "0"
["tnid"]=>
string(1) "0"
["translate"]=>
string(1) "0"
["vid"]=>
string(3) "206"
["revision_uid"]=>
string(2) "16"
["title"]=>
string(18) "Pcv (campus Aalst)"
["body"]=>
string(0) ""
["teaser"]=>
string(0) ""
["log"]=>
string(0) ""
["revision_timestamp"]=>
string(10) "1301323146"
["format"]=>
string(1) "0"
["nd_switch_bm"]=>
string(0) ""
["name"]=>
string(12) "stage.revaki"
["picture"]=>
string(0) ""
["data"]=>
string(72) "a:1:{s:13:"form_build_id";s:37:"form-f89b99e4a5249b192ff472579b826b00";}"
["field_stagedomein_audiologo"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_geneeskunde"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_lo"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_revaki"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(3) "152"
}
}
["field_stagedomein_verpleeg"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_status"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(14) "niet opgegeven"
}
}
["field_status_datum"]=>
array(1) {
[0]=>
array(4) {
["value"]=>
NULL
["timezone"]=>
string(15) "Europe/Brussels"
["timezone_db"]=>
string(15) "Europe/Brussels"
["date_type"]=>
string(4) "date"
}
}
["field_locatieview"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
string(3) "179"
}
}
["field_status_extra"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_status_stagedomein"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(6) "Actief"
}
}
["field_maxcapstud_stagedomein"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(2) "18"
}
}
["field_status_bevestigd_door"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
NULL
}
}
["field_aanpers_stageplaats"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
NULL
}
}
["field_extrainfo_stagedomein"]=>
array(1) {
[0]=>
array(2) {
["value"]=>
string(37) "Capaciteit: 3 studenten alle periodes"
["format"]=>
NULL
}
}
["field_percapaciteit_stageplaats"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_aanplaats_stageplaats"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_mentoren"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
string(3) "178"
}
}
["field_persoon_stagedomein"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
NULL
}
}
["has_body"]=>
string(1) "0"
["taxonomy"]=>
array(0) {
}
}
[1]=>
object(stdClass)#24 (45) {
["nid"]=>
string(3) "211"
["type"]=>
string(11) "stageplaats"
["language"]=>
string(2) "nl"
["uid"]=>
string(2) "33"
["status"]=>
string(1) "1"
["created"]=>
string(10) "1291281467"
["changed"]=>
string(10) "1301323440"
["comment"]=>
string(1) "0"
["promote"]=>
string(1) "0"
["moderate"]=>
string(1) "0"
["sticky"]=>
string(1) "0"
["tnid"]=>
string(1) "0"
["translate"]=>
string(1) "0"
["vid"]=>
string(3) "218"
["revision_uid"]=>
string(2) "16"
["title"]=>
string(53) "Mss ( Privaatpraktijk kinesitherapie Walravens Marc )"
["body"]=>
string(0) ""
["teaser"]=>
string(0) ""
["log"]=>
string(0) ""
["revision_timestamp"]=>
string(10) "1301323440"
["format"]=>
string(1) "0"
["nd_switch_bm"]=>
string(0) ""
["name"]=>
string(12) "stage.revaki"
["picture"]=>
string(0) ""
["data"]=>
string(72) "a:1:{s:13:"form_build_id";s:37:"form-f89b99e4a5249b192ff472579b826b00";}"
["field_stagedomein_audiologo"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_geneeskunde"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_lo"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_revaki"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(3) "128"
}
}
["field_stagedomein_verpleeg"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_status"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(14) "niet opgegeven"
}
}
["field_status_datum"]=>
array(1) {
[0]=>
array(4) {
["value"]=>
NULL
["timezone"]=>
string(15) "Europe/Brussels"
["timezone_db"]=>
string(15) "Europe/Brussels"
["date_type"]=>
string(4) "date"
}
}
["field_locatieview"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
string(3) "210"
}
}
["field_status_extra"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_status_stagedomein"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(6) "Actief"
}
}
["field_maxcapstud_stagedomein"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
string(1) "4"
}
}
["field_status_bevestigd_door"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
NULL
}
}
["field_aanpers_stageplaats"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
NULL
}
}
["field_extrainfo_stagedomein"]=>
array(1) {
[0]=>
array(2) {
["value"]=>
string(40) "Capaciteit: 1 student in periode 3 tem 6"
["format"]=>
NULL
}
}
["field_percapaciteit_stageplaats"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_aanplaats_stageplaats"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_mentoren"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
string(3) "208"
}
}
["field_persoon_stagedomein"]=>
array(1) {
[0]=>
array(1) {
["nid"]=>
NULL
}
}
["has_body"]=>
string(1) "0"
["taxonomy"]=>
array(0) {
}
}
[2]=>
object(stdClass)#26 (45) {
["nid"]=>
string(3) "217"
["type"]=>
string(11) "stageplaats"
["language"]=>
string(2) "nl"
["uid"]=>
string(2) "33"
["status"]=>
string(1) "1"
["created"]=>
string(10) "1291281906"
["changed"]=>
string(10) "1301323440"
["comment"]=>
string(1) "0"
["promote"]=>
string(1) "0"
["moderate"]=>
string(1) "0"
["sticky"]=>
string(1) "0"
["tnid"]=>
string(1) "0"
["translate"]=>
string(1) "0"
["vid"]=>
string(3) "224"
["revision_uid"]=>
string(2) "16"
["title"]=>
string(54) "Mss ( Privaatpraktijk kinesitherapie Peeters Stefaan )"
["body"]=>
string(0) ""
["teaser"]=>
string(0) ""
["log"]=>
string(0) ""
["revision_timestamp"]=>
string(10) "1301323440"
["format"]=>
string(1) "0"
["nd_switch_bm"]=>
string(0) ""
["name"]=>
string(12) "stage.revaki"
["picture"]=>
string(0) ""
["data"]=>
string(72) "a:1:{s:13:"form_build_id";s:37:"form-f89b99e4a5249b192ff472579b826b00";}"
["field_stagedomein_audiologo"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_geneeskunde"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
["field_stagedomein_lo"]=>
array(1) {
[0]=>
array(1) {
["value"]=>
NULL
}
}
The object is at the index 0 in the array, so you just access the property names from there
echo $theArray[0]->title;
No offense, but if you really have to ask that I strongly suggest to tighten your grip on the language by actually reading through the PHP manual's Language Reference, especially
这篇关于如何从数组中获取对象(stdClass)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!