【问题标题】:Php returning array from json, but I need the data as a stringPhp从json返回数组,但我需要数据作为字符串
【发布时间】:2014-03-15 00:57:50
【问题描述】:

所以我正在为自己设置一个小页面来查看我在狗狗币中的在线交易。

我已建立 RPC 服务器/客户端连接并正常工作。 listtransactions 方法为我提供了作为数组的交易历史记录,该数组分解为其元素。我将这些嵌入到表格中。

一切正常。我想要的是获取交易 ID 并将其链接到狗狗币区块链记录。

这是代码,然后我会注意哪些行有问题:

    for($i=count($json)-1; $i>=0; $i--){
    echo '<tr>';
    echo '<td>'.$json[$i]['address'].'</td>'."\n";
    //echo '<td>'.$json[$i]['category'].'</td>'."\n";
    echo '<td>'.$json[$i]['amount'].'</td>'."\n";
    //echo '<td>'.$json[$i]['confirmations'].'</td>'."\n";
    echo '<td>'."<a href='https://dogechain.info/tx/$json[$i]['txid']'>".$json[$i]
['txid'].'</a>        </td>'."\n";
    echo '</tr>';
    }
    echo '</table></center>';
    ?>

包含超链接的行是它搞砸的地方。你可以在http://www.suchco.in/看到它是如何显示的

它给我的示例链接是:https://dogechain.info/tx/Array%5B 它应该是:https://dogechain.info/tx/ fab3b949cb3a71e79fa6b631d5d16aa7268b77dc3626e2fb2e711f1b43adc08d

我怎样才能做到这一点?

【问题讨论】:

    标签: php arrays rpc


    【解决方案1】:

    { } 放在字符串中的数组变量周围。

    尝试: {$json[$i]['txid']}

    而不是: $json[$i]['txid']

    进行字符串连接

    echo '&lt;td&gt;'."&lt;a href='https://dogechain.info/tx/".$json[$i]['txid']."'&gt;"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-02
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-05
      • 1970-01-01
      相关资源
      最近更新 更多