php - 如何修复 JSON 响应中 Datetime 带来的空间
问题描述
我想删除从日期时间获得的空间。因为这个 JSON 格式无效。以下是我的 JSON 响应:
{
"txId": "226334",
"createdAt":"2019-06-20
18: 33: 51","details":"Transfered
out","account_name_2":"","currency":"myr","amount":"-44.00","balance":"44,
272.80"}
下面是我的代码
$data['transactions'] = [];
foreach ($transactions as $tx) {
$data['transactions'][] = array(
'txId' => $tx['id'],
'createdAt' => trim($tx['created_at']),
'details' => str_replace(" "," ",$this->lang->line($tx['description'])),
'account_name_2' => isset($merchants[$tx['account_name_2']]) ? $merchants[$tx['account_name_2']] : $tx['account_name_2'],
'currency' => $currency,
'amount' => $tx['amount'] > 0 ? '+' . number_format($tx['amount'] * $forex['buy_in'], 2) : number_format($tx['amount'] * $forex['buy_in'], 2),
'balance' => number_format($total * $forex['buy_in'], 2)
);
$total -= number_format($tx['amount'] * $forex['buy_in'], 2);
}
$this->respSuccess($data);
解决方案
推荐阅读
- javascript - 我如何编写一个函数来从数组中随机选择一个名称而不选择最后一个元素
- excel - EXCEL VBA/SELEIUM“单击按钮”<>找不到元素错误
- flutter - 带有 socket.io-client 的 Flutter 应用程序在发出时冻结
- jhipster - “--skip-client”实体参数是否可以仅应用于某些实体?
- python - 如何将 HTML canvas img 发送和读取到 python api?
- python - GIF 只显示第一帧 - PIL
- jenkins - 如何在声明性 Jenkins 文件中的 Jenkins 多管道中设置反应选择参数
- python-3.x - 在 Mint (Ubuntu) Linux 上恢复 Python3 安装 -- 导入 json
- node.js - cron 任务未运行
- c# - C# 用列表重复列表并合并列表