如何从PHP中的JSON响应中删除字符串中的双引号

时间:2018-05-12 06:11:14

标签: php arrays json string bitcoin

我遇到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);

1 个答案:

答案 0 :(得分:0)

你不需要删除任何东西。当您在添加双引号的字符串上调用json_encode时会出现此问题。

所以只需删除json_encode来电,就应该像魅力一样:

$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;
相关问题