PingPlusPlus / pingpp-php

MIT License
378 stars 182 forks source link

关于对象数据格式化 #21

Closed henter closed 9 years ago

henter commented 9 years ago

没找到显式的方法可以调。。 只能尝试以下:

尝试拿到json

$json = (string)$charge;

但是,尝试拿到array时就醉了。。出来一大坨***

$array = (array)$charge;

所以要先转json再转array ?

$array = json_decode((string)$charge, true);

= =!!

samurai00 commented 9 years ago

不知道你要转成 array 做什么,如果只是取里面的元素的话,可以直接取的,$charge['id']

henter commented 9 years ago

我想把charge对象保存下来而已 😳

Sent from Outlook

On Mon, Jun 15, 2015 at 4:55 AM -0700, "afon" notifications@github.com wrote:

不知道你要转成 array 做什么,如果只是取里面的元素的话,可以直接取的,$charge['id'] 。

— Reply to this email directly or view it on GitHub.

samurai00 commented 9 years ago

保存到数据库吗?保存到数据库的话,你可以选择保存 JSON 格式的。

henter commented 9 years ago

好吧 谢啦

Sent from Outlook

On Mon, Jun 15, 2015 at 5:24 AM -0700, "afon" notifications@github.com wrote:

保存到数据库吗?保存到数据库的话,你可以选择保存 JSON 格式的。

— Reply to this email directly or view it on GitHub.