Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. // Count total number of elements in an array using an iterative function
  2. function arrElementCounter($vr) {
  3. $totCnt = 0;
  4. foreach($vr as $vrVv) {
  5. if(!empty($vrVv) && is_array($vrVv)) {
  6. $totCnt += iter8r($vrVv);
  7. } else {
  8. $totCnt++;
  9. }
  10. }
  11. return $totCnt;
  12. }
  13.  
  14. // Test the function output by passing an array
  15. echo arrElementCounter($_POST);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement