字符串:[Name] => google [AF] => 0 [AX] => 2 [AL] => 1 [DZ] => 0 .....
输出:
[AX,2]
[AL,1]
列表中排除了[0]条目的国家/地区
I have tried using sql but i want for php
Select '[AF,' + LTrim(Cast(Sum(AF) as varChar(5))) + ']'
From Table Where name = 'Andy'
Union
Select '[AS,' + LTrim(Cast(Sum(AS) as varChar(5))) + ']'
From Table Where name = 'Andy'
Union
Select '[AQ,' + LTrim(Cast(Sum(AQ) as varChar(5))) + ']'
From Table Where name = 'Andy'
还有 http://sqlfiddle.com/#!2/42756/5
但我需要在php
答案 0 :(得分:0)
一个简单的foreach循环可以解决这个问题:
foreach($array AS $key=>$value){
if($value!=0){
echo "$key,$value";
}
}