我的$ _REQUEST是以下
Array
(
[city] => Antalya
[country] => Turcia
[DesinationId] => A99O
[In] => 2015-04-29
[Out] => 2015-05-01
[rooms] => Array
(
[0] => Array
(
[adult] => 2
[child] => 0
)
[2] => Array
(
[adult] => 1
[child] => 0
)
)
[PHPSESSID] => 195897227bcf5ff2772632d7063b7ba7
[_ga] => GA1.2.45498464.1425755756
)
我试图统计来自两个房间的成人和孩子
$adults = ($_REQUEST->rooms[0]->adult + $_REQUEST->rooms[2]->adult)
但结果是0,任何想法?
答案 0 :(得分:4)
$adults = ($_REQUEST['rooms'][0]['adult'] + $_REQUEST['rooms'][2]['adults']);
好$_REQUEST
不是stdClass
的实例,它是一个数组,因此您可以像数组一样访问它