note 71015 added to function.count

From: Date: Wed, 08 Nov 2006 12:28:14 +0000
Subject: note 71015 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-119509@lists.php.net to get a copy of this message
My function returns the number of elements in array for multidimensional arrays subject to depth of array. (Almost COUNT_RECURSIVE, but you can point on which depth you want to plunge). <? function getArrCount ($arr, $depth=1) { if (!is_array($arr) || !$depth) return 0; $res=count($arr); foreach ($arr as $in_ar) $res+=getArrCount($in_ar, $depth-1); return $res; } ?> ---- Server IP: 195.222.164.18 Probable Submitter: 193.111.92.109 ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- https://master.php.net/note/edit/71015 Del: integrated -- https://master.php.net/note/delete/71015/integrated Del: useless -- https://master.php.net/note/delete/71015/useless Del: bad code -- https://master.php.net/note/delete/71015/bad+code Del: spam -- https://master.php.net/note/delete/71015/spam Del: non-english -- https://master.php.net/note/delete/71015/non-english Del: in docs -- https://master.php.net/note/delete/71015/in+docs Del: other reasons-- https://master.php.net/note/delete/71015 Reject -- https://master.php.net/note/reject/71015 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119509) next »