• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
李先森博客
博客园    首页    新随笔    联系   管理    订阅  订阅

截取邮箱格式以及统计邮箱总数

建立email.php

<?php
    header('content-type:text/html;charset=UTF-8');
    $link = mysqli_connect("localhost","root","123456","exam","3306");
    $sql = "set names utf8";
    $sql = "select * from user_user";
    $re = mysqli_query($link,$sql);
    while($arr = mysqli_fetch_assoc($re)){
        $data[] = $arr;
    }
    if ($data=='') {
        echo "<script>alert('为空');</script>";
    }else{
        foreach($data as $key=>$v){
            $ema=ltrim(strstr($v['email'],'@'),"@");
            $email[$ema][]=$ema;
        }
    }
    // print_r($data);


    ?>

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>邮箱</title>
    </head>
    <body>
        <?php foreach($email as $key=>$v){ ?>
        <?php echo $key; ?>的邮箱<?php echo count($v); ?>个<br/>
        <?php } ?>

    </body>
    </html>

代码仅供参考。。。关键看思路

posted @ 2016-06-28 15:47  李先森博客  阅读(304)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3