[英]How to use json_decode on PHP
我有以下JSON字符串:
{"createLead":{"client_id":42891}}
需要使用PHP解析此字符串以獲取client_id
值。 使用以下命令:
$json_result= json_decode('{"createLead":{"client_id":42891}}', true);
如何使用響應數組獲取client_id
值? 以下命令不起作用,並返回空字符串:
$client_id = $json_result['createLead']['client_id'];
使用此代碼
<?php
$json = '{"createLead":{"client_id":42891}}';
$json_result= json_decode($json, true);
echo $json_result['createLead']['client_id'];
?>
Output: 42891
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.