Home  >  Article  >  Backend Development  >  PHP calculates the number of elements in an array that are not empty

PHP calculates the number of elements in an array that are not empty

WBOY
WBOYOriginal
2016-07-25 08:54:331303browse
  1. $arr = array(
  2. 1=>"11",
  3. 2=>"22",
  4. 3=>"33",
  5. 4=>""
  6. );
  7. print_r(count(array_filter($arr)));
  8. ?>
Copy code


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn