【发布时间】:2011-06-24 17:49:14
【问题描述】:
我有一个包含状态对象的数组,这些状态对象包含一个类似对象的数组,还包含评论对象
我的问题是,现在我的数组中有对象,如何将它们拉回来?这样我以后可以将它们保存到数据库中。
感谢您的帮助
安迪
例如
Array
(
[0] => cStatus Object
(
[statusId:cStatus:private] => 123123123
[message:cStatus:private] => powpowpow
[updated_time:cStatus:private] => 2011-01-27T15:52:48+0000
[likes:cStatus:private] => Array
(
)
[comments:cStatus:private] => Comment Object
(
[commentId:Comment:private] => 123123123
[created_time:Comment:private] => 2011-01-30T20:18:50+0000
[message:Comment:private] => Kazam
[name:Comment:private] => Blue man
[createdBy:Comment:private] => 124124
[likes:Comment:private] => Array
(
)
)
)
[1] => cStatus Object
(
[statusId:cStatus:private] => 5125125
[message:cStatus:private] => Gawdam fruit and fibre is tasty :D
[updated_time:cStatus:private] => 2011-01-25T20:21:56+0000
[likes:cStatus:private] => Array
(
[0] => Like Object
(
[likeId:Like:private] => 120409086
[name:Like:private] => Jt
)
)
[comments:cStatus:private] => Array
(
)
)
[2] => cStatus Object
(
[statusId:cStatus:private] => 5215215
[message:cStatus:private] => Dear 2
[updated_time:cStatus:private] => 2011-01-18T08:28:50+0000
[likes:cStatus:private] => Array
(
[0] => Like Object
(
[likeId:Like:private] => 2456
[name:Like:private] => Edw2r
)
[1] => Like Object
(
[likeId:Like:private] => 2452412
[name:Like:private] => aw1
)
[2] => Like Object
(
[likeId:Like:private] => 12412411
[name:Like:private] => wqw
)
)
[comments:cStatus:private] => Array
(
)
)
)
【问题讨论】:
-
这不是将数组转换为对象,是吗?
-
:) 刚刚意识到我可以只做 $myObjArray[0]->methodCall(),所以我将把它包装在一个遍历每个元素的 for 循环中
-
是的,你只有一个对象数组。
标签: php arrays object multidimensional-array