Yii is used to count the number of mailboxes of different types. yii is used to count the number of mailboxes.
This example describes how Yii counts the number of mailboxes of different types. We will share this with you for your reference. The details are as follows:
:
Controller:
// Query the mailbox public function actionEmail () {/* // query all mailbox data (1 type) $ arr = Users: find ("select * from users ") -> asArray ()-> all (); // var_dump ($ data); die; $ data = array (); // retrieve the mail type 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; // obtain the number of mailboxes of different types foreach ($ data as $ key => $ v) {echo $ key. "the email address is ". count ($ v ). ". "<br>";} */(two methods) $ 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. "the email address is ". $ v. ". "<br> ";}}