S
S
Semyon Leonidovich Dynka2014-06-15 23:15:00
PHP
Semyon Leonidovich Dynka, 2014-06-15 23:15:00

Parse json in PHP

I have a multidimensional JSON array:
{
"date2" : "20140616",
"min" : {
"denial" : 0,
"visits" : 4,
"new_visitors_perc" : 0.4343,
"page_views" : 12,
"visit_time" : 70 ,
"depth" : 1.733,
"new_visitors" : 3,
"visitors" : 4
},
"max" : {
"denial" : 0.2988,
"visits" : 396,
"new_visitors_perc" : 0.75,
"page_views" : 1017,
" visit_time" : 157,
"depth" : 3,
"new_visitors" : 226,
"visitors" : 354
},
"data" : [
{
"wday" : 0,
"denial" : 0,
"visits" : 4,
"new_visitors_perc" : 0.75,
"page_views" : 12,
"date" : "20140616",
"visit_time" : 82,
"depth" : 3,
"new_visitors" : 3,
"visitors" : 4,
"id" : "20140616"
},
{
"wday" : 6,
"denial" : 0.2045,
"visits" : 176,
"new_visitors_perc" : 0.5542,
"page_views" : 393,
"date" : "20140615",
"visit_time" : 104,
"depth" : 2.233,
"new_visitors" : 92,
"visitors" : 166,
"id" : "20140615"
},
{
etc
It is necessary to output in the end in the following form:
"date": "value",
"visits": value,
"pageviews": value
And so for each of the elements .
And if it's even more difficult: how to get it all in reverse order? Those. so that the last element in the array is the first in the response?
How to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-06-15
@bande

we translate JSON into an array via json_decode, iterate through it as we need, output it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question