/ LJCPHPCodeDoc / LJCCollectionLib / LJCCollectionBase / RetrieveItemAtIndex


Parameters
$index - The element index.

Returns

The object at the index parameter.

Syntax

PHP
public function RetrieveItemAtIndex($index)

Retrieves the item by index.

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;
   }
 
   // Retrieves the item by index.
   public function RetrieveAtIndex($index)
   {
     $retItem = $this->RetrieveItemAtIndex($index);
     return $retItem;
   }
 }
 
 // Retrieves the item by index.
 private static function RetrieveItemAtIndex()
 {
   $names = new Names();
   $names->Add("First");
   $names->Add("Second");
   $names->Add("Third");
   $result = $names->RetrieveAtIndex(0);
 
   // result:
   // First
 }

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