ASD
ASD

Reputation: 4957

php array usage in javascript, jquery

Using JsonEncode I got a php array in Javascript. How I can get the modified array back to php?

Upvotes: 0

Views: 169

Answers (2)

Carl
Carl

Reputation: 1263

To get a JSON string to a PHP object:

$obj = json_decode($some_json);
echo $obj->field1; // where field1 is a known field

TO get a JSON string to an associative array:

$arr = json_decode($some_json, true);
echo $arr['field1'];

Upvotes: 0

Alex
Alex

Reputation: 3190

As I understood you need json_decode() function. You can easily convert array encoded in json-format to the php-array

Upvotes: 1

Related Questions