note 64257 added to function.array-count-values
| From: | jd.belllocatedatgood | Date: | Tue, 11 Apr 2006 01:14:08 +0000 |
| Subject: | note 64257 added to function.array-count-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107733@lists.php.net to get a copy of this message | ||
(eat that webbots!)
I believe counting multi-dimensional arrays has been built into PHP since 4.2:
<?php
$star_wars = array(
'jedi' => array( 'yoda', 'obi-wan kenobi', 'luke
skywalker' ),
'sith' => array( 'darth maul', 'darth sidious', 'darth
vader' ),
'other' => array( 'wicket', 'han solo', 'chewbaca' )
);
// counting elements from all dimensions
echo "<br>" . count( $star_wars, COUNT_RECURSIVE ); // output 12
// counting only second dimension elements
echo "<br>" . ( count( $star_wars, COUNT_RECURSIVE ) - count( $star_wars ) ); //
output 9
?>
----
Server IP: 64.71.164.2
Probable Submitter: 66.255.16.50 (proxied: 1.1 Symantec_Web_Security (3.0.1.75))
----
X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER,
HTML_MESSAGE autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-count-values.php
Edit -- http://master.php.net/note/edit/64257
Del: integrated -- http://master.php.net/note/delete/64257/integrated
Del: useless -- http://master.php.net/note/delete/64257/useless
Del: bad code -- http://master.php.net/note/delete/64257/bad+code
Del: spam -- http://master.php.net/note/delete/64257/spam
Del: non-english -- http://master.php.net/note/delete/64257/non-english
Del: in docs -- http://master.php.net/note/delete/64257/in+docs
Del: other reasons-- http://master.php.net/note/delete/64257
Reject -- http://master.php.net/note/reject/64257
Search -- http://master.php.net/manage/user-notes.php