Created
August 13, 2022 19:37
-
-
Save galvao/3a08dfc46191674f26f77730b754fd71 to your computer and use it in GitHub Desktop.
The most convoluted way of counting the entries in a collection?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Given a collection that implements the Iterator interface: | |
* @see https://www.php.net/manual/en/class.iterator | |
*/ | |
return (int)!empty($collection->entries) * ($collection->key() + 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment