如何让count()计算一组数组中的所有元素?
$a[0] = 1;
$a[1] = 3;
$a[2] = 5;
$b[0] = 2;
$b[1] = 4;
$b[2] = 6;
$c[0] = 8;
$c[1] = 9;
$c[2] = 10;
$result = count($a, $b, $c);
echo $result;
答案 0 :(得分:2)
count()
期待一个或两个参数,但你给它三个。
你可以使用,
array_sum(array_map('count', [$a, $b, $c]));