/ LJCPHPCodeDoc / LJCCollectionLib / LJCCollectionBase / count


Returns

The element count.

Syntax

PHP
public function count(): int

Enables count(object).

Example

PHP
 // The strongly typed collection class.
 class Names extends LJCCollectionBase
 {
   // Adds a string.
   // This method makes a string collection strongly typed.
   public function Add(string $text)
   {
     $retItem = $this->AddItem($text);
     return $retItem;
   }
 }
 
 // Indicates if a key already exists.
 private static function HasKey()
 {
   $names = new Names();
   $names->Add("First");
   $names->Add("Second");
   $names->Add("Third");
   $result = count($names);
 
   // result:
   // 3;
 }

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.