如何从 PHP 中的 JSON 响应中删除字符串中的双引号
How to remove double quotes from a string from JSON response in PHP
我对 BlockChain API 响应有疑问。从钱包中获取地址时,地址用双引号括起来,如下所示。如何去除引号?
"1Dgyv8Qz1nkrJddoyLBepv1RUXSDqCBCdp"
代码:
$resp = file_get_contents($blockchain_receive_root . "v2/receive?key=" . $my_api_key . "&gap_limit=".$gap_limit. "&callback=" . urlencode($callback_url) . "&xpub=" . $my_xpub);
$response = json_decode($resp);
print json_encode($response->address);
您不需要删除任何内容。当您在添加双引号的字符串上调用 json_encode
时会出现问题。
所以只需删除 json_encode
调用,它就会像 charm 一样工作:
$resp = file_get_contents($blockchain_receive_root . "v2/receive?key=" . $my_api_key . "&gap_limit=".$gap_limit. "&callback=" . urlencode($callback_url) . "&xpub=" . $my_xpub);
$response = json_decode($resp);
print $response->address;
我对 BlockChain API 响应有疑问。从钱包中获取地址时,地址用双引号括起来,如下所示。如何去除引号?
"1Dgyv8Qz1nkrJddoyLBepv1RUXSDqCBCdp"
代码:
$resp = file_get_contents($blockchain_receive_root . "v2/receive?key=" . $my_api_key . "&gap_limit=".$gap_limit. "&callback=" . urlencode($callback_url) . "&xpub=" . $my_xpub);
$response = json_decode($resp);
print json_encode($response->address);
您不需要删除任何内容。当您在添加双引号的字符串上调用 json_encode
时会出现问题。
所以只需删除 json_encode
调用,它就会像 charm 一样工作:
$resp = file_get_contents($blockchain_receive_root . "v2/receive?key=" . $my_api_key . "&gap_limit=".$gap_limit. "&callback=" . urlencode($callback_url) . "&xpub=" . $my_xpub);
$response = json_decode($resp);
print $response->address;