我正在使用mysql和Php,我得到的数据格式如下:
Array
(
[country] => India
[total] => 23
)
Array
(
[country] => USA
[total] => 1
)
Array
(
[country] => Japan
[total] => 1
)
我希望如果有任何国家的完全匹配,它们应该以以下格式在同一个数组中。
Array
(
[country] => India
[total] => 23
)
Array
(
[country] => USA,Japan
[total] => 1
)
这是我的MySQL查询
SELECT country,COUNT(*) as total FROM doctors GROUP BY country ORDER BY COUNT(*) DESC
这是我的代码
<?php foreach ($data as $total) {
echo "<pre>";print_R($total);
?>
<p><?php echo $total['country']; ?><?php echo $total['total']; ?></p>
<?php } ?>