伙计们,这是mysql表的输出。它显示month(Value)
获取count(Total)
特定疾病。现在我有一个array()
12 个月的 php,我想与该数组进行比较,并发现如果对于特定月份,它们没有从表中返回的数据,则0
在其他新array()
的 12 个月中添加该月的数据,或者从表中找到的值。
Value | dname | Total
5 | Root Canal | 1
8 | Root Canal | 1
我在 php 中的代码
foreach($ResultArray2[1] as $key => $val){
if(empty($row_d['Value'])){
$ResultArray2[$i][$key] = '0';
else
$ResultArray2[$i][$row_d['Value']] = $row_d['Total'];
这就是我得到的
Array ( [1] => Array ( [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [2] => Array ( [5] => 1 [8] => 1 )
)
这就是我需要的数组(
[1] => Array ( [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 [6] => 0 [7] => 0 [8] => 0 [9] => 0 [10] => 0 [11] => 0 [12] => 0 ) [2] => Array ( [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 1 [6] => 0 [7] => 0 [8] => 1 [9] => 0 [10] => 0 [11] => 0 [12] => 0 )
)