search
Homephp教程PHP开发How Yii counts the number of different types of mailboxes

The example in this article describes how Yii counts the number of different types of mailboxes. Share it with everyone for your reference, the details are as follows:

Rendering:

How Yii counts the number of different types of mailboxes

Controller:

//查询邮箱
public function actionEmail()
{
   /* //查询所有邮箱数据(1种)
   $arr=Users::find("select * from users")->asArray()->all();
   //var_dump($data);die;
   $data=array();
   //取出邮箱类型
   foreach($arr as $key=>$v)
   {
    $str=substr($v['email'],strpos($v['email'],"@"),50);
    $str1=substr($str,1);
    $data[$str1][$key]=$str1;
   }
   //var_dump($data);die;
  //获得不同类型邮箱个数
  foreach($data as $key=>$v)
  {
   echo $key."的邮箱有".count($v)."个"."<br>";
  }*/
  (2种方法)
  $arr=Users::find()->select("email")->column();
  $data=array();
  foreach($arr as $key=>$v)
  {
    $pos=strpos($v,"@");
    $str=substr($v,$pos+1);
    $data[]=$str;
  }
  //var_dump($data);die;
  $count=array_count_values($data);
  // var_dump($count);die;
   foreach($count as $key=>$v)
  {
   echo $key."的邮箱有".$v."个"."<br>";
  }
}

I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.

For more related articles on how Yii counts the number of different types of mailboxes, please pay attention to the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)