Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Count total number of elements in an array using an iterative function
- function arrElementCounter($vr) {
- $totCnt = 0;
- foreach($vr as $vrVv) {
- if(!empty($vrVv) && is_array($vrVv)) {
- $totCnt += iter8r($vrVv);
- } else {
- $totCnt++;
- }
- }
- return $totCnt;
- }
- // Test the function output by passing an array
- echo arrElementCounter($_POST);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement