uno
uno

Reputation: 867

PHP: Count input type with value

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

Answers (1)

Sougata Bose
Sougata Bose

Reputation: 31739

This should work -

count(array_filter($_POST['a']))

array_filter will remove the empty values from array.

array_filter()

Upvotes: 1

Related Questions