【发布时间】:2013-04-04 08:23:31
【问题描述】:
我在 jquery 中使用 JSON.stringify(pageSettings) 将数组 ajax 到 php 并保存文件。文件内容:
{"MidHeight":367,"BotTop":502}
我使用 json_decode 将其加载回 php 中的数组:
$pageSettings=json_decode(file_get_contents($path.$file);
当我 print_r($pageSettings,true) 结果是:
stdClass Object
(
[MidHeight] => 276
[BotTop] => 411
)
但是当我尝试从中读取时:
$pageSettings["MidHeight"]
我明白了:
PHP Fatal error: Cannot use object of type stdClass as array.
【问题讨论】:
标签: php jquery arrays json associative-array