Array
(
[0] => Zimbabwe
[country] => Zimbabwe
[1] => 2
[counts] => 2
)
Array
(
[0] => Tunisia
[country] => Tunisia
[1] => 6
[counts] => 6
)
I want output like below:
Array
(
[country] => Zimbabwe
[counts] => 2
)
Array
(
[country] => Tunisia
[counts] => 6
)
试着用
从数据库中获取while($rowCountry = mssql_fetch_array($resultCountryCount), MSSQL_ASSOC){
print_r($rowCountry);
}
或
while($rowCountry = mssql_fetch_assoc($resultCountryCount)){
print_r($rowCountry);
}
最好使用@mark
,否则您也可以尝试这个
$a = Array
(
0 => 'Zimbabwe',
'country' => 'Zimbabwe',
1=> 2,
'counts' => 2,
);
function myfun($array){
$check= array();
foreach($array as $k => $v){
if(in_array($v,$check)){
unset($array[$k]);
}
array_push($check, $v);
}
return $array;
}
$a = myfun($a);
echo '<pre>';
print_r($a);