我已经看到了这里的所有解决方案,但似乎无法理解它。
array (size=340)
0 =>
object(stdClass)[92]
public 'name' => string 'page_fan_adds_unique' (length=20)
public 'period' => string 'day' (length=3)
public 'values' =>
array (size=3)
0 =>
object(stdClass)[93]
public 'value' => int 0
public 'end_time' => string '2016-07-01T07:00:00+0000' (length=24)
1 =>
object(stdClass)[94]
public 'value' => int 0
public 'end_time' => string '2016-07-02T07:00:00+0000' (length=24)
2 =>
object(stdClass)[95]
public 'value' => int 0
public 'end_time' => string '2016-07-03T07:00:00+0000' (length=24)
public 'title' => string 'Daily New Likes' (length=15)
public 'description' => string 'Daily: The number of new people who have liked your Page (Unique Users)' (length=71)
public 'id' => string '1791907811022418/insights/page_fan_adds_unique/day' (length=50)
我可以遍历主阵列并回显名称,tittle&描述,但似乎无法访问values数组。
我在第一个foreach中写了这个但是抛出了一个objtostring错误
@foreach($value->values as $key)
{{$key->value}}
@endforeach
我确信它很简单,可以在JS中轻松完成,但在PHP中没那么经验,感谢您的帮助
<?php var_dump($value->values) ?>
尝试倾倒它让我玩游戏
array (size=3)
0 =>
object(stdClass)[93]
public 'value' => int 0
public 'end_time' => string '2016-07-01T07:00:00+0000' (length=24)
1 =>
object(stdClass)[94]
public 'value' => int 0
public 'end_time' => string '2016-07-02T07:00:00+0000' (length=24)
2 =>
object(stdClass)[95]
public 'value' => int 0
public 'end_time' => string '2016-07-03T07:00:00+0000' (length=24)
已经尝试过很多东西,但仍无法循环使用它。
NEW UPDATE
已将其转换为json,然后循环遍历它并尝试转储。
$array = json_decode(json_encode($value->values), True);
// var_dump($array);
for ($i=0; $i < count($array); $i++) {
var_dump($array[$i]);
}
结果
array (size=2)
'value' => int 0
'end_time' => string '2016-07-01T07:00:00+0000' (length=24)
array (size=2)
'value' => int 0
'end_time' => string '2016-07-02T07:00:00+0000' (length=24)
array (size=2)
'value' => int 0
'end_time' => string '2016-07-03T07:00:00+0000' (length=24)
我现在如何循环使用以提取价值&amp; end_time?