我有这个数组:
result script loadedArray
(
[2015-06] => Array
(
[nb_uniq_visitors] => 12
[nb_users] => 0
[nb_visits] => 12
[nb_actions] => 51
[nb_visits_converted] => 0
[bounce_count] => 4
[sum_visit_length] => 1574
[max_actions] => 22
[bounce_rate] => 33%
[nb_actions_per_visit] => 4.3
[avg_time_on_site] => 131
)
)
我希望能够将其作为对象访问我该怎么做?我有
$object = new stdClass();
foreach ($arrayme as $key => $value) {
$object->$key = $value;
}
但是不能$object->2015-06->nb_visits
来访问数组对象。
答案 0 :(得分:0)
您必须将数组转换为对象。
$arr->{'2015-06'}->nb_uniq_visitors
然后您可以访问'20/03/2014'-'01/02/2015'=312
。