Tencent / Tencent/Biny

可以统计重复数量吗?

Open
#100 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
1.7k
Forks
253
PR merge metrics
No merged PRs in 30d

Description

在写一个项目,需要统计表中的每个“publish”的数量并列出来,比如说表“list”:

+------+----------+
|  id  | publish  |
+------+----------+
| 1    |   小明   |
| 2    |   小红   |
| 3    |   小刚   |
| 4    |   小明   |
| 5    |   小明   |
| 6    |   小刚   |
| 7    |   小明   |
| 8    |   小刚   |
+------+----------+

然后我想要结果是:

 array(
        array('小明'=>4),
        array('小刚'=>3),
        array('小红'=>1),
);

请问要怎么写?(对不起,我PHP还是新手)

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file, test, or entry point is named; start by reviewing how this PHP project accesses the example list table and the issue's requested result. Done means producing one count for each distinct publish value, matching the shown array format.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
database
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.