我在大括号内有以下值。
{ "address": "[email protected] ", "did_you_mean": null, "is_valid": true, "parts": { "display_name": null, "domain": "test.com", "local_part":“测试”}}
我需要获取“is_valid”的值。我尝试使用 json_decode 来获取该值。但这并没有帮助我找到结果。请任何人帮我找到解决方案。
最佳答案
为什么 json_decode 不起作用? 我用该代码对其进行了测试并且运行良好:
$str= '{ "address": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="afdbcadcdbefdbcadcdb81ccc0c2" rel="noreferrer noopener nofollow">[email protected]</a>", "did_you_mean": null, "is_valid": true, "parts": { "display_name": null, "domain": "test.com", "local_part": "test" }}';
$obj = json_decode($str);
echo $obj->is_valid;
关于php - 如何在 PHP 中提取大括号内的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43087827/