【问题标题】:Json decode in wordpress在wordpress中进行Json解码
【发布时间】:2017-06-01 10:54:58
【问题描述】:

这里我在本地主机中使用此代码

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

它工作正常...如果我使用

print_r($fromdata); 

它打印以下格式

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

。在 wordpress 中使用相同的代码 print_r($fromdata); return {\"patientid\":\"16\",\"name\":\"Ravindran\"} this。并且无法获得价值

如何从这个对象中获取价值 谢谢

【问题讨论】:

  • 执行print_r($_POST["data"]);会得到什么?

标签: php json wordpress


【解决方案1】:

你可以试试这个。

<?php

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

$data = stripslashes($data);

$return = json_decode($data);



print_r($return);

【讨论】:

  • 是的。这解决了它。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多