jpganz18
jpganz18

Reputation: 5858

how could I read/parse an object list of javascript using PHP?

I am currently trying to figure out how to parse this, yet, no solution found.

My problem is that I am getting a object on this way: (this is a console.debug result)

[Object { id=32193, value="user 1"},
 Object { id=42203, value="user 3"}, 
Object { id=41747, value="user 4"} .....]

I tried with this function thinking could be json format

http://us.php.net/manual/en/function.json-decode.php

but no result yet.. any idea which is the best way to do it?

THanks

Upvotes: 0

Views: 37

Answers (1)

DhruvPathak
DhruvPathak

Reputation: 43235

This is a javascript object. To convert it into PHP object, convert this javascript object into a JSON string.

var jsonStr = JSON.stringify(myObj); // pass this string to PHP,

in PHP use json_decode($jsonStr) ( where $jsonStr is received through GET or POST.

Upvotes: 1

Related Questions