首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >file_get_contents遍历api数据

file_get_contents遍历api数据

作者头像
红目香薰
发布于 2022-11-29 17:34:44
发布于 2022-11-29 17:34:44
7030
举报
文章被收录于专栏:CSDNToQQCodeCSDNToQQCode

使用【bootstrap】框架

关键代码:

file_get_contents("API路径");

代码语言:javascript
复制
    <table class="table table-hover table-bordered table-striped" style="text-align: center;">
        <tr style="background-color: #F6F9FE;">
            <th>编号</th>
            <th>标题</th>
            <th>路径</th>
            <th>状态</th>
        </tr>
        <?php
            $file_contents = file_get_contents("http://127.0.0.1:7777/blog/public/columns/FindAll");
            $arr=json_decode($file_contents,true);
            for($i=0;$i<count($arr);$i++) {
                ?>
                    <tr>
                        <td><?php echo $arr[$i]['id']; ?></td>
                        <td><?php echo $arr[$i]["title"]?></td>
                        <td><?php echo $arr[$i]["url"]?></td>
                        <td><?php echo $arr[$i]["state"]?></td>
                    </tr>
                <?php
            }
        ?>
    </table>
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-12-12,如有侵权请联系 cloudcommunity@tencent.com 删除
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档