【发布时间】:2014-12-17 17:18:45
【问题描述】:
我想用 PHP 数组做点什么。我写了一个函数来做一些我会说的事情。我的输入数组是:
Array
(
[0] => stdClass Object
(
[message] => Automated XML Site Map Generator
http://pastebin.com/xjJe38dp
[id] => 103114753133019_371405176303974
[from] => stdClass Object
(
[id] => 735588533186829
[name] => Mohammad Mostafa Shahreki
)
[created_time] => 2013-04-26
[updated_time] => 2013-04-26
)
[1] => stdClass Object
(
[message] => Simple but powerful DB class
http://pastebin.com/1qgxUrwX
[id] => 103114753133019_371404696304022
[from] => stdClass Object
(
[id] => 735588533186829
[name] => Mohammad Mostafa Shahreki
)
[created_time] => 2013-04-26
[updated_time] => 2013-04-26
)
[2] => stdClass Object
(
[message] => Convert Existing DB to Unicode
http://pastebin.com/pHu08cPs
[id] => 103114753133019_371404609637364
[from] => stdClass Object
(
[id] => 735588533186829
[name] => Mohammad Mostafa Shahreki
)
[created_time] => 2013-04-26
[updated_time] => 2013-04-26
)
[3] => stdClass Object
(
[message] => thanks mosthafa ,,,, for adding me to this group
[id] => 103114753133019_103333343111160
[from] => stdClass Object
(
[id] => 10155092057165556
[name] => HalF PixeL
)
[created_time] => 2011-10-11
[updated_time] => 2011-11-21
)
)
我想将每个数据保存在我的 MySQL 数据库中。例如,我想通过一个函数保存 message,id,from->name,created_time。我试图编写一个 foreach 循环,但找不到添加 from->name 的方法,它是一个 stdClass,不能与 ['from']['name'] 一起使用。你能告诉我怎么做吗?
【问题讨论】:
-
['from']->名字,名字是一个属性
-
嘿。我有一个这样的数组!!!!如你所知,我不能在他们附近互相使用。我该怎么办?
标签: php mysql arrays facebook-php-sdk