Suppose you have this:
while ($record = mysql_fetch_assoc($dbquery)) {
$arr[] = $record['$columnvalue1'];
}
$arraycount = count($arr);
and you want multiple columns in the array how is this done?
while ($record = mysql_fetch_assoc($dbquery)) {
$arr[] = array($record['$columnvalue1'],$record['$columnvalue2']);
}
$arraycount = count($arr);
the above code errors:
Warning: array_count_values(): Can only count STRING and INTEGER values!
To add multiple column values in to an array
$arr = array();
while ($record = mysql_fetch_array($dbquery)) {
array_push($arr,$record['$columnvalue1'],$record['$columnvalue2']);
}
To find the sum of the array
$arraycount = array_sum($arr); //to find the sum of the array
$num = sizeof($arr); //to find the size of the array
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.