note 47553 deleted from function.count by cmb
| From: | cmb@php.net | Date: | Tue, 04 Oct 2016 18:06:35 +0000 |
| Subject: | note 47553 deleted from function.count by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-206768@lists.php.net to get a copy of this message | ||
Note Submitter: freefaler at gmail dot com
----
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
?>