用json关联数组的对象(解码/编码)

时间:2015-11-18 14:30:31

标签: php arrays json object

我有一个想要转换为assoc array的对象。 我为此使用json,但结果是:

Array([0] => Array([id]=>12 [label]=>home)

但我需要 Array([id]=>12 [label]=>home),否则$page["id"]将无效。

如何解决此问题?

代码:

$page = json_decode(json_encode($page),true);
$id = $page["id"];

0 个答案:

没有答案
相关问题