如何计算PHP数组中的非空条目?
考虑:
[name] => Array ( [1] => name#1
[2] => name#2
[3] => name#3
[4] => name#4
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
)
$name = $_POST['name']
我希望结果是.4
count ($name) = 9
count (isset($name)) = 1
count (!empty($name)) = 1
我认为最后一个会完成我需要的东西,但事实并非如此(空条目来自表单上未填充的输入)。