/ LJCPHPCodeDoc / LJCCommonLib / LJC / ToArray


Parameters
$items - The collection object.

Syntax

PHP
public static function ToArray($items): array

Copy collection items to an indexed array.

Example

PHP
 class Names extends LJCCollectionBase
 {
   public function Add(string $text)
   {
     $this->AddItem($text);
   }
 
   public string $Name;
 }
 
 // Copy collection items to an indexed array.
 private static function ToArray()
 {
   $names = new Names();
   $names->Add("First");
   $array = LJC::ToArray($names);
   $result = $array[0];
 
   // result:
   // First
 }

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