截取邮箱格式以及统计邮箱总数
建立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>
代码仅供参考。。。关键看思路