2 Replies - 187 Views - Last Post: 30 January 2012 - 09:46 PM Rate Topic: -----

Topic Sponsor:

#1 scottyadam  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 103
  • Joined: 03-December 07

Json string to PHP array

Posted 30 January 2012 - 04:52 PM

Ok I am really confused...but hopefully somebody can clear this up for me. I have an ajax application that sends a json string to my php application however, in the json string is an array of objects. This is what is output by firebug:

query	"[{\"id\": \"222\", \"name\": \"spectacular fizz\", \"price\": \"3.59\"}, {\"id\": \"222\", \"name\": \"spectacular fizz\", \"price\": \"3.59\"}]"



when I get this into my PHP application, this is what the array looks like in a variable. (OH, and btw...yes i used the json_decode function before all this)

"[{"id": "222", "name": "spectacular fizz", "price": "3.59"}, {"id": "222", "name": "spectacular fizz", "price": "3.59"}]"



I have searched high and low...has somebody not made a php function that would convert this into a PHP array of objects?

thanks.

This post has been edited by scottyadam: 30 January 2012 - 04:54 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Json string to PHP array

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 1940
  • View blog
  • Posts: 7,295
  • Joined: 08-August 08

Re: Json string to PHP array

Posted 30 January 2012 - 05:38 PM

It looks to me like the objects are json encoded, so you'd need to decode them too.
Was This Post Helpful? 0
  • +
  • -

#3 AdaHacker  Icon User is offline

  • Resident Curmudgeon

Reputation: 377
  • View blog
  • Posts: 739
  • Joined: 17-June 08

Re: Json string to PHP array

Posted 30 January 2012 - 09:46 PM

View Postscottyadam, on 30 January 2012 - 06:52 PM, said:

has somebody not made a php function that would convert this into a PHP array of objects?

That would be json_decode().
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1