Home Backend Development PHP Tutorial How to count the number of different types of mailboxes through Yii

How to count the number of different types of mailboxes through Yii

Jun 15, 2018 am 11:26 AM
yii statistics

This article mainly introduces Yii's method of counting the number of different types of mailboxes, involving Yii database queries and string traversal, interception and judgment related operation skills. Friends in need can refer to the following

Examples of this article This article introduces Yii's method of counting the number of different types of mailboxes. Share it with everyone for your reference, the details are as follows:

Rendering:

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>";
  }
}
Copy after login

The above is the entire content of this article , I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Yii and CKEditor implement the image upload function

How to use the Bootbox plug-in to implement a custom popup in Yii2 Window

#How to use PHPExcel to export Excel files in Yii2 framework

The above is the detailed content of How to count the number of different types of mailboxes through Yii. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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 ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to implement data statistics and analysis in uniapp How to implement data statistics and analysis in uniapp Oct 24, 2023 pm 12:37 PM

How to implement data statistics and analysis in uniapp 1. Background introduction Data statistics and analysis are a very important part of the mobile application development process. Through statistics and analysis of user behavior, developers can have an in-depth understanding of user preferences and usage habits. Thereby optimizing product design and user experience. This article will introduce how to implement data statistics and analysis functions in uniapp, and provide some specific code examples. 2. Choose appropriate data statistics and analysis tools. The first step to implement data statistics and analysis in uniapp is to choose the appropriate data statistics and analysis tools.

How to use SQL statements for data aggregation and statistics in MySQL? How to use SQL statements for data aggregation and statistics in MySQL? Dec 17, 2023 am 08:41 AM

How to use SQL statements for data aggregation and statistics in MySQL? Data aggregation and statistics are very important steps when performing data analysis and statistics. As a powerful relational database management system, MySQL provides a wealth of aggregation and statistical functions, which can easily perform data aggregation and statistical operations. This article will introduce the method of using SQL statements to perform data aggregation and statistics in MySQL, and provide specific code examples. 1. Use the COUNT function for counting. The COUNT function is the most commonly used

How to quickly build a statistical chart system under the Vue framework How to quickly build a statistical chart system under the Vue framework Aug 21, 2023 pm 05:48 PM

How to quickly build a statistical chart system under the Vue framework. In modern web applications, statistical charts are an essential component. As a popular front-end framework, Vue.js provides many convenient tools and components that can help us quickly build a statistical chart system. This article will introduce how to use the Vue framework and some plug-ins to build a simple statistical chart system. First, we need to prepare a Vue.js development environment, including installing Vue scaffolding and some related plug-ins. Execute the following command in the command line

Implementation of linear and pie chart functions in Vue statistical charts Implementation of linear and pie chart functions in Vue statistical charts Aug 19, 2023 pm 06:13 PM

The linear and pie chart functions of Vue statistical charts are implemented in the field of data analysis and visualization. Statistical charts are a very commonly used tool. As a popular JavaScript framework, Vue provides convenient methods to implement various functions, including the display and interaction of statistical charts. This article will introduce how to use Vue to implement linear and pie chart functions, and provide corresponding code examples. Linear graph function implementation A linear graph is a type of chart used to display trends and changes in data. In Vue, we can use some excellent

Use Google Analytics to count website data in Beego Use Google Analytics to count website data in Beego Jun 22, 2023 am 09:19 AM

With the rapid development of the Internet, the use of Web applications is becoming more and more common. How to monitor and analyze the usage of Web applications has become a focus of developers and website operators. Google Analytics is a powerful website analytics tool that can track and analyze the behavior of website visitors. This article will introduce how to use Google Analytics in Beego to collect website data. 1. To register a Google Analytics account, you first need to

How to use MySQL's COUNT function to count the number of rows in a data table How to use MySQL's COUNT function to count the number of rows in a data table Jul 25, 2023 pm 02:09 PM

How to use MySQL's COUNT function to count the number of rows in a data table. In MySQL, the COUNT function is a very powerful function that is used to count the number of rows in a data table that meet specific conditions. This article will introduce how to use MySQL's COUNT function to count the number of rows in a data table, and provide relevant code examples. The syntax of the COUNT function is as follows: SELECTCOUNT(column_name)FROMtable_nameWHEREconditi

Steps of statistical analysis Steps of statistical analysis Jun 28, 2023 pm 03:27 PM

Statistical analysis often refers to the process of sorting, classifying and interpreting collected relevant data. The basic steps of statistical analysis include: 1. Collect data; 2. Organize data; 3. Analyze data.

Do you know how to count people in excel? Do you know how to count people in excel? Mar 20, 2024 pm 01:30 PM

As one of the commonly used office software, Excel is an indispensable good partner in our life and work. We often use it to count people, which is also the most common operation. For veterans who are familiar with Excel, using it to count people is a matter of minutes; but if you are a novice, using ecxel to count people is simply difficult! So how to use it? I compiled a document today, I hope it can help you! Let’s take a look together! Method 1: [Use functions to count people] (as shown in the picture) We enter [=COUNT(B2:B6)] in the bottom unit cell; then, press [Enter] to get the number of people. Method 2: [Use the status bar to count people] (as shown in the picture). 1. We click the mouse

See all articles