Considerare:Come contare le voci non vuote in un array PHP?
[name] => Array ([1] => name#1
[2] => name#2
[3] => name#3
[4] => name#4
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
)
$name = $_POST['name']
Voglio che il risultato sia 4
.
count ($name) = 9
count (isset($name)) = 1
count (!empty($name)) = 1
penserei che quest'ultimo sarebbe realizzare quello che serve, ma non è (le voci vuote sono da ingressi vuoti sul modulo).
Si noti che questo non restituisce solo elementi vuoti, ma ogni elemento il cui valore è [uguale a 'false'] (http://php.net/manual/en/language.types.boolean.php#language.types. boolean.casting) (cioè '" "', 'null',' 0', 'false',' "0" '). – Gumbo