$list=Array
(
[page] => Array
(
[page_id] => 1,
[path] => tiyee.html,
[templates] => zj001.tpl,
[key] => 21212121,
), [qianggou] => Array
(
[object_id] => 1,
[number] => 0,
[oldprice] => 0.00,
[newprice] => 0.00,
[begintime] => 0000-00-00 00:00:00,
[endtime] => 0000-00-00 00:00:00,
[limit_b] => 0000-00-00 00:00:00,
[limit_e] => 0000-00-00 00:00:00,
[type] => 1,
[saleout] => 0,
[classtime] => 0000-00-00 00:00:00,
[page_id] => 1,
), [miaosha] => Array
(
[object_id] => 2,
[number] => 0,
[oldprice] => 0.00,
[newprice] => 0.00,
[begintime] => 2010-04-18 23:42:10,
[endtime] => 2010-04-18 23:42:10,
[limit_b] => 2010-04-18 23:42:10,
[limit_e] => 2010-04-18 23:42:10,
[type] => 2,
[saleout] => 0,
[classtime] => 0000-00-00 00:00:00,
[page_id] => 1,
))echo '<pre>';
print_r($list['page']);结果为什么是1?明明应该是个数组啊?
(
[page] => Array
(
[page_id] => 1,
[path] => tiyee.html,
[templates] => zj001.tpl,
[key] => 21212121,
), [qianggou] => Array
(
[object_id] => 1,
[number] => 0,
[oldprice] => 0.00,
[newprice] => 0.00,
[begintime] => 0000-00-00 00:00:00,
[endtime] => 0000-00-00 00:00:00,
[limit_b] => 0000-00-00 00:00:00,
[limit_e] => 0000-00-00 00:00:00,
[type] => 1,
[saleout] => 0,
[classtime] => 0000-00-00 00:00:00,
[page_id] => 1,
), [miaosha] => Array
(
[object_id] => 2,
[number] => 0,
[oldprice] => 0.00,
[newprice] => 0.00,
[begintime] => 2010-04-18 23:42:10,
[endtime] => 2010-04-18 23:42:10,
[limit_b] => 2010-04-18 23:42:10,
[limit_e] => 2010-04-18 23:42:10,
[type] => 2,
[saleout] => 0,
[classtime] => 0000-00-00 00:00:00,
[page_id] => 1,
))echo '<pre>';
print_r($list['page']);结果为什么是1?明明应该是个数组啊?
print_r($list['page']);#你输出的键值有单引号,而你的原数组的所有键值都将没有单引号,建议就爱那个原数组所有键值都加上单引号$list=array
(
['page'] => array
(
['page_id'] => 1,
……
'page' => array (
'page_id' => 1,
'path' => 'tiyee.html',
'templates' => 'zj001.tpl',
'key' => 21212121
)
);
print_r($list['page']);没问题的。
还有
如果我
echo $list['page']['templates']
直接报错:Fatal error: Cannot use string offset as an array in 。。
不过为了贴到这个论坛,我用echo '<pre>';print_r($list);输出后,加了符号贴上来的,错误的原因是 提示 $list['page']['templates']是个数组而不是变量,但是 ,我这个明显是个变量啊?