假设你有这个:
while ($record = mysql_fetch_assoc($dbquery)) {
$arr[] = $record['$columnvalue1'];
}
$arraycount = count($arr);
并且您希望数组中的多个列如何完成?
while ($record = mysql_fetch_assoc($dbquery)) {
$arr[] = array($record['$columnvalue1'],$record['$columnvalue2']);
}
$arraycount = count($arr);
以上代码错误:
Warning: array_count_values(): Can only count STRING and INTEGER values!
答案 0 :(得分:1)
将多个列值添加到数组
$arr = array();
while ($record = mysql_fetch_array($dbquery)) {
array_push($arr,$record['$columnvalue1'],$record['$columnvalue2']);
}
查找数组的总和
$arraycount = array_sum($arr); //to find the sum of the array
$num = sizeof($arr); //to find the size of the array