充分利用json_de code数组结果 [英] Getting an array result from json_decode
本文介绍了充分利用json_de code数组结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何得到一个数组,结果从 json_de code()
?
How do I get an array as a result from json_decode()
?
我有一个这样的数组:
$array = array(
'mod_status' => 'yes',
'mod_newsnum' => 5
);
和我保存在这个数据库中的JSON一样连接code:
and I saved this in database like JSON encode:
{"mod_status":"yes","mod_newsnum":5}
现在我想从数据库中再得到阵列。但是当我使用:
Now I want to get array again from database. But when i use:
$decode = json_decode($dbresult);
我得到:
stdClass Object (
[mod_status] => yes
[mod_newsnum] => 5
)
而不是一个数组。我怎样才能得到一个数组,而不是一个对象?
Instead of an array. How can I get an array instead of an object?
推荐答案
json_de $的第二个参数C $ç
为true以强制关联数组:
Set the second parameter of json_decode
to true to force associative arrays:
$decode = json_decode($dbresult, true);
这篇关于充分利用json_de code数组结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文