Reputation: 867
Hi I want to count input type with value
<input type="text" name="a[]" value="Test1">
<input type="text" name="a[]" value="Test2">
<input type="text" name="a[]" value="">
PHP Code:
echo count($_POST['a']);
The output is 3. I want to get only the input type with value which is 2.
I want my output to be 2
Thank you
Upvotes: 0
Views: 161
Reputation: 31739
This should work -
count(array_filter($_POST['a']))
array_filter
will remove the empty values from array.
Upvotes: 1