ccszfdasr 2021-03-16 18:16 采纳率: 90.9%
浏览 80
已采纳

PHP返回数据整理求教

1.php

<?php error_reporting(0);
$handle = fopen ("http://adm.fxtcvip.com/user_get_user_info?token=3ePdlaQDXxyNnCmA1613651742395", "rb");
$content = "";
do {
$data = fread($handle, 1024);
if (strlen($data) == 0) {
break;
}
$content.= $data;
} while(true);
fclose ($handle);

echo $content;

执行上面PHP返回代码如下

$content = 

{"code":0,"data":{"create_time":"2021-02-18 20:35:40","id":3205,"ip_time":600,"longtime_ip_amount":0,"mobile_cost":6,"mobile_price":2500,"month_amount":1400,"month_cost_amount":36,"month_init_amount":0,"password":"mima123","price":1200,"res_static_api_cost":0,"res_static_cost":14,"res_static_price":2000,"status":1,"total_amount":1400,"update_time":"2021-03-13 05:01:53","user_name":"nemayonghu","white_list_status":1},"msg":"\u6210\u529f"}

 

代码应该怎么写想整理和计算得到答案

 

 left_amount = data.month_amount 减去data.month_cost_amount 减去data.mobile_cost-data.res_static_cost

 $(".left_amount").text(left_amount 除以100)  得到最后的结果金额 + %70   再除以7 =

 

最终想得到的答案

目前剩余  ¥XXXXXXX

 

 

代码该怎么写啊麻烦大哥们帮帮忙!!!!

  • 写回答

4条回答 默认 最新

  • 斯洛文尼亚旅游 2021-03-16 20:39
    关注

    month_amount-month_cost_amount-mobile_cost-res_static_cost=?
    在用上面减后得到的结果除以100
    除后得到的结果加70%
    加70%后的结果在除以7

     

    <?php
    $content = '{"code":0,"data":{"create_time":"2021-02-18 20:35:40","id":3205,"ip_time":600,"longtime_ip_amount":0,"mobile_cost":6,"mobile_price":2500,"month_amount":1400,"month_cost_amount":36,"month_init_amount":0,"password":"mima123","price":1200,"res_static_api_cost":0,"res_static_cost":14,"res_static_price":2000,"status":1,"total_amount":1400,"update_time":"2021-03-13 05:01:53","user_name":"nemayonghu","white_list_status":1},"msg":"\u6210\u529f"}';
    $o=json_decode($content);
    $left_amount =$o->data->month_amount - $o->data->month_cost_amount - $o->data->mobile_cost - $o->data->res_static_cost;
    $left_amount/=100;//除以100
    $left_amount+=$left_amount*0.7;//加上70%
    $left_amount/=7;//结果在除以7
    $left_amount=round($left_amount,2);//四舍五入保留2位小数
    echo "目前剩余  ¥".$left_amount;
    ?>
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 openwrt双栈NAT
  • ¥15 部分网页页面无法显示!
  • ¥15 怎样解决power bi 中设置管理聚合,详细信息表和详细信息列显示灰色,而不能选择相应的内容呢?
  • ¥15 QTOF MSE数据分析
  • ¥15 平板录音机录音问题解决
  • ¥15 请问维特智能的安卓APP在手机上存储传感器数据后,如何找到它的存储路径?
  • ¥15 (SQL语句|查询结果翻了4倍)
  • ¥15 Odoo17操作下面代码的模块时出现没有'读取'来访问
  • ¥50 .net core 并发调用接口问题
  • ¥15 网上各种方法试过了,pip还是无法使用