0

I'm triyng to get a count from array like below

CASE 1
Array ( [0] => [1] => [2] => [3] => [4] => [5] => )

CASE 2
Array ( [0] => name [1] => telephone [2] => [3] => [4] => [5] => )

If I use COUNT, results is 5
echo count($array);

I'm like to get 0 (in case 1) and 2 (in case 2)

Exist a way to do this?

1
  • Filter your array first and remove all values which you want to remove before you count the array or just count the values you want. Commented Mar 4, 2017 at 22:43

1 Answer 1

1

Use this:

$remove_empty = array_filter($your_array);  
print_r($remove_empty);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.