sirin k
sirin k

Reputation: 373

How to access particular fields from JSON content by using php?

i want to get the values of different fields in Json by using php

Upvotes: 0

Views: 1024

Answers (1)

dabito
dabito

Reputation: 586

json_decode($string) will return an object from which you can get the values you assigned.

For example:

$myObject = new MyObject();
$myObject -> att1 = 5;

$string = json_encode($myObject);

//here's how you get the value:

$myJsonDecodedObject = json_decode($string);
$value = $myJsonDecodedObject -> att1;

Upvotes: 2

Related Questions