note 47553 added to function.count

From: Date: Sat, 20 Nov 2004 01:01:53 +0000
Subject: note 47553 added to function.count
Groups: php.notes 
Request: Send a blank email to php-notes+get-80787@lists.php.net to get a copy of this message
If you want to count only elements in the second level of 2D arrays.A close to mind note, useful for multidimentional arrays: <?php $food = array('fruits' => array('orange', 'banana', 'apple'), 'veggie' => array('carrot', 'collard','pea')); // recursive count echo count($food,COUNT_RECURSIVE); // output 8 // normal count echo count($food); // output 2 // all the fruits and veggies echo (count($food,COUNT_RECURSIVE)-count($food,0)); //output 6 ?> ---- Manual Page -- http://www.php.net/manual/en/function.count.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+47553 Delete -- http://master.php.net/manage/user-notes.php?action=delete+47553&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47553&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47553&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47553&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47553&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47553&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+47553&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#80787) next »