ccszfdasr 2021-03-16 22:07 采纳率: 90.9%
浏览 58
已采纳

php返回数据整理?

2.php


〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
<?php error_reporting(0);
$ken=$_POST['ken'];
$ipz=$_POST['ipz'];
$handle = fopen ("http://adm.fxtcvip.com/user_add_whitelist?token=$ken&remark=&ip=$ipz", "rb");
$contents = "";
do {
$data = fread($handle, 1024);
if (strlen($data) == 0) {
break;
}
$contents.= $data;
} while(true);
fclose ($handle);
if(isset($_POST["ken"]))
echo file_get_contents("http://adm.fxtcvip.com/user_get_whitelist?token=".$_POST["ken"]);

echo "<br><br><br><br><br><br><br><br><br><br>复制网址,网址最后填写你要删除的ip,打开即可:  http://adm.fxtcvip.com/user_del_whitelist?token=$ken&ip=";
?>

〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
打开php返回数据如下

{"code":0,"data":[{"create_time":"2021-03-16 18:18:57","id":34248,"ip":"1.1.1.1","remark":"","update_time":"2021-03-16 18:18:57"},{"create_time":"2021-03-13 02:43:39","id":34125,"ip":"113.250.211.54","remark":"","update_time":"2021-03-13 02:43:39"},{"create_time":"2021-03-11 16:43:19","id":33966,"ip":"13.13.13.13","remark":"","update_time":"2021-03-11 16:43:19"},{"create_time":"2021-03-11 12:10:55","id":33945,"ip":"121.121.121.11","remark":"","update_time":"2021-03-11 12:10:55"},{"create_time":"2021-03-11 12:09:19","id":33944,"ip":"121.121.121.10","remark":"","update_time":"2021-03-11 12:09:19"},{"create_time":"2021-03-10 11:36:45","id":33883,"ip":"114.99.200.228","remark":"","update_time":"2021-03-10 11:36:45"},{"create_time":"2021-03-10 11:34:56","id":33882,"ip":"15.15.15.15","remark":"","update_time":"2021-03-10 11:34:56"}],"msg":"\u6210\u529f"}

复制网址,网址最后填写你要删除的ip,打开即可: http://adm.fxtcvip.com/user_del_whitelist?token=3ePdlaQDXxyNnCmA1613651742395&ip=


〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓

2.php里代码怎么写,可以把返回的数据整理为以下结果

ip白名单                                   添加ip时间

1.1.1.1                                    2021-03-16 18:18:57

113.250.211.54                             2021-03-13 02:43:39

13.13.13.13                                2021-03-11 16:43:19

复制网址,网址最后填写你要删除的ip,打开即可: http://adm.fxtcvip.com/user_del_whitelist?token=3ePdlaQDXxyNnCmA1613651742395&ip=

  • 写回答

3条回答 默认 最新

  • 斯洛文尼亚旅游 2021-03-16 22:39
    关注
    <?php
    //$content=file_get_contents("http://adm.fxtcvip.com/user_get_whitelist?token=".$_POST["ken"]);
    //用$content存储file_get_contents返回的内容而不是直接输出
    $content = '{"code":0,"data":[{"create_time":"2021-03-16 18:18:57","id":34248,"ip":"1.1.1.1","remark":"","update_time":"2021-03-16 18:18:57"},{"create_time":"2021-03-13 02:43:39","id":34125,"ip":"113.250.211.54","remark":"","update_time":"2021-03-13 02:43:39"},{"create_time":"2021-03-11 16:43:19","id":33966,"ip":"13.13.13.13","remark":"","update_time":"2021-03-11 16:43:19"},{"create_time":"2021-03-11 12:10:55","id":33945,"ip":"121.121.121.11","remark":"","update_time":"2021-03-11 12:10:55"},{"create_time":"2021-03-11 12:09:19","id":33944,"ip":"121.121.121.10","remark":"","update_time":"2021-03-11 12:09:19"},{"create_time":"2021-03-10 11:36:45","id":33883,"ip":"114.99.200.228","remark":"","update_time":"2021-03-10 11:36:45"},{"create_time":"2021-03-10 11:34:56","id":33882,"ip":"15.15.15.15","remark":"","update_time":"2021-03-10 11:34:56"}],"msg":"\u6210\u529f"}';
    $o=json_decode($content);
    $l=count($o->data);
    $content="<table cellpadding='10'><tr><td>ip白名单</td><td> 添加ip时间</td></tr>";
    for($i=0;$i<$l;$i++){
    $content.="<tr><td>".$o->data[$i]->ip."</td><td>".$o->data[$i]->create_time."</td></tr>";
    }
    $content.="</table>";
    
    echo $content;
    
    echo "<br><br><br><br><br><br><br><br><br><br>复制网址,网址最后填写你要删除的ip,打开即可:  http://adm.fxtcvip.com/user_del_whitelist?token=$ken&ip=";
    ?>
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历