【问题标题】:How to remove double quotes from a string from JSON response in PHP如何从 PHP 中 JSON 响应的字符串中删除双引号
【发布时间】:2018-05-12 06:11:13
【问题描述】:

我对 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);

【问题讨论】:

  • 您的问题甚至没有显示出解决问题的最小努力。请阅读How to ask 或先尝试使用搜索功能。无论如何,由于这看起来相当简单,请参阅我的答案。

标签: php arrays json string bitcoin


【解决方案1】:

您无需删除任何内容。当您在添加双引号的字符串上调用 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;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-19
    • 1970-01-01
    相关资源
    最近更新 更多