我需要在图表中显示一些数据。基本上我有一个来自数据库的数组,它看起来像这样-
[
[0] =>[
[user_type] => 'Manager'
[total_count] => 3
],
[1] =>[
[user_type] => 'Director'
[total_count] => 2
]
]
还有一个user_type是Trainee 。如果用户Trainee有0 Total_count它不会出现在上面的数组中。所以我需要手动添加。所以首先将检查user_type3 个 user_types 中哪个不存在于上面的数组中。如果不存在则只需要添加total_count 0.
最后我想要的数组应该是这样的——
[
['labels'] =>['Manager','Director','Trainee],
['dataset'] => [ 3, 2, 0 ]
]
请注意这里,正确的顺序非常重要。所以在上面的数组中,Manager 有 3 个,Director 有 2 个,实习生有 0 个总数。
慕少森
MMMHUHU
神不在的星期二