I am having the following json:
{
"data": [
{
"id": "116376655202954/insights/page_impressions_organic/day",
"name": "page_impressions_organic",
"period": "day",
"values": [
{
"value": 13059,
"end_time": "2013-02-22T08:00:00+0000"
},
{
"value": 15223,
"end_time": "2013-02-23T08:00:00+0000"
},
And I using PHP to get the values of value and end_time the following foreach:
foreach ($page_impressions_organic['data'] as $page_impression_organic) {
foreach($page_impression_organic['values'] as $key => $page_impression_organic_values) {
$end_time = strval($page_impression_organic_values['end_time']);
$ds = substr($end_time, 0, -14);
$value = intval($page_impression_organic_values['value']);
echo '[\'' . $ds . '\', ' . $value . ']';
}}
Everything is working like it should, my issue is that now I have a different json:
{
"data": [
{
"id": "116376655202954/insights/page_storytellers_by_story_type/day",
"name": "page_storytellers_by_story_type",
"period": "day",
"values": [
{
"value": {
"fan": 2043,
"page post": 293,
"user post": 5
},
"end_time": "2013-02-22T08:00:00+0000"
},
{
"value": {
"fan": 1085,
"page post": 398,
"user post": 5
},
"end_time": "2013-02-23T08:00:00+0000"
},
and I am not able to get the same results because value is an array and I specially need only the page post values from it. I need to keep the form that my echo has for further scopes. I've made another foreach for like this:
foreach ($page_talking_abouts['data'] as $page_talking_about) {
foreach($page_talking_about['values'] as $key => $page_talking_about_values) {
foreach($page_talking_about_values['value'] as $page_talking_about_value) {
$end_time = strval($page_talking_about_values['end_time']);
$ds = substr($end_time, 0, -14);
$value = intval($page_talking_about_value['page post']);
echo '[\'' . $ds . '\', ' . $value . ']';
}}}
but $value is 0 everytime... What I have to do?
end_timeisn't withinvalue. Get rid of the 3rdforeachloop.