zoukankan      html  css  js  c++  java
  • 通过PHP来 获取文件内容 并且分割字符串 呈现在表格中

    <?php
    
    $aaa = file_get_contents("names.txt");
    $data = explode("
    ", $aaa);
    foreach ($data as $key) {
        if (!$key) continue;
        else {
            $col = explode('|', $key);
            $final[] = $col;
        }
    }
    ?>
    <!doctype html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport"
              content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
            table td {
                text-align: center;
            }
        </style>
    </head>
    <body>
    <div>
        <table>
            <thead>
            <tr>
                <td>编号</td>
                <td>姓名</td>
                <td>年龄</td>
                <td>邮箱</td>
                <td>网址</td>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($final as $item): ?>
            <tr>
                <?php foreach ($item as $val): ?>
                    <?php $temp = trim($val); ?>
                    <?php if (strpos($temp, 'http://') === 0): ?>
                        <td><a href="<?php echo strtolower($temp) ?>"><?php echo substr($temp,7) ?></a></td>
                    <?php else : ?>
                        <td><?php echo $val; ?></td>
                    <?php endif ?>
                <?php endforeach ?>
    
                <?php endforeach ?>
            </tbody>
        </table>
    </div>
    </body>
    </html>
  • 相关阅读:
    hello world!
    react(一):组件的生命周期
    position和BFC
    继承
    绕不开的this
    js世界这么大,闭包想看看
    js中数组常用方法总结
    Appium混合应用测试
    手机APP兼容性测试
    运行monitor提示需要安装旧JAVA SE 6运行环境
  • 原文地址:https://www.cnblogs.com/Lzxgg-xl/p/10540702.html
Copyright © 2011-2022 走看看