php - Get values from Json code -
this json code
[ {"prospectid":"87f3278e-c9ee-4775-abc6-4813969d45a5", "firstname":"erter", "lastname":"nurtertel", "emailaddress":"null", "company":"null", "phone":"null", "mobile":"456456456", "total":"690"}, {"prospectid":"00969dcd-5c03-450e-832c-063e976285d5", "firstname":"rter", "lastname":"erte", "emailaddress":"null", "company":"null", "phone":"56456456", "mobile":"null", "total":"690"} ]
in code need prospectid.how prospectid in array php code?
first of need change json string.
put " "
around null.
use following code fetch value of 'prospectid'
$json = '[{"prospectid":"87f3278e-c9ee-4775-abc6-4813969d45a5","firstname":"erter","lastname":"nurtertel","emailaddress":"null","company":"null","phone":"null","mobile":"456456456","total":"690"},{"prospectid":"00969dcd-5c03-450e-832c-063e976285d5","firstname":"rter","lastname":"erte","emailaddress":"null","company":"null","phone":"56456456","mobile":"null","total":"690"}]'; $data = json_decode($json); for($i=0; $i<count($data); $i++ ){ $prospectid = $data[$i]->{'prospectid'}; echo $prospectid."<br>"; }
Comments
Post a Comment