iphone - using PHP to create multidimensional array from simple JSON array -


I have a php query that returns the following JSON format from the table. "Member": "18", "Eugene FK": "30", "Login Name": "Johnson", "Name": "Frank", "Age": "23 "," Location ":" school ",},

this requires the following format:

  [{" memberid ":" 18 "{ "User": "30", "login name": "John", "name": "frank", "age": "23", "location": "school",}},  

I was told in another question that PHP will work and it seems that "transparency" may be appropriate, I have to find out what to put in PHP before returning JSN Hia.

My Array. The list will look like the following:

  Route: dictionary V lines: Array V Item 0: Dictionary Title: String 18 V Child Array V Item 0 Title String 30 etc.  

Thanks in advance.

I'm not completely sure that I understand what you want to do. I think you want to make JSN data in an array in PHP, and then want to rearrange your content to spread the two dimensions?

Php comes with two very nifty functions called "json_decode" and "json_encode" that allow you to decode Jason data into decode and encode.

A note about "json_decode" until you give the secondary parameter as a function, it will return an object, and not a multi-dimensional array.

Example:

  & lt; "User": "18", "user idfk": "30", "login name": "johnson", "name", "php", "age": "23", "location": $ strJsonData = '["member" "Junk", "Name": "Bill", "Frank", "Age": "", "Member": "19", "User IDF": "36", "Login Name" Age ":" 34 "," Location ":" Work "}] '; $ ArrRawJsonData = json_decode ($ strJsonData, true); # Now $ arrRawJsonData contains a two-dimensional array of all your Jason data $ IntJsonDataCount = Calculation ($ ArrRawJsonData); {$ intMemberId = (int) ($ arrRawJsonData [$ i] ['subscriber']) for $ $ ($ i = 0; $ i  

The result of the above code will be:

  array ([18] = & gt; Hey ([useridFK] = & gt; 30 [loginname] = & gt; Johnson [name] = & gt; frank [era] => 23 [place] => school ) [1 9] => Hey ([useridFK] => 36 [login name] => Jones [name] => Gtc: 

Comments

Post a Comment

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -