Json decode in wordpress

2019-09-19 13:01发布

here I use this code in my local host

$fromdata= $_POST["data"];
$fromValue=json_decode($fromdata);
$patientid=  $fromValue->patientid;
$patientname= $fromValue->name;

its working fine... if i use

print_r($fromdata); 

it print the following format

{"patientid":"55","name":"Sow"}

. the same code is used in wordpress the print_r($fromdata); return {\"patientid\":\"16\",\"name\":\"Ravindran\"} this. and unable to get value

how to get value from this object thanks

1条回答
Evening l夕情丶
2楼-- · 2019-09-19 13:59

You can try this.

<?php

$data = '{\"patientid\":\"16\",\"name\":\"Ravindran\"}';

$data = stripslashes($data);

$return = json_decode($data);



print_r($return);
查看更多
登录 后发表回答