PHP Classes

File: Sample.php

Recommend this page to a friend!
  Classes of tobytobs   PHP File Array   Sample.php   Download  
File: Sample.php
Role: Example script
Content type: text/plain
Description: Sample usage of the filearray class
Class: PHP File Array
Store and retrieve values from files as arrays
Author: By
Last change:
Date: 10 years ago
Size: 617 bytes
 

Contents

Class file image Download
<?php

   
/**
     *
     * FileArray class example
     * A less memory footprint simple array manipulation for PHP
     *
     * Example file
     */
    
    
require_once(__DIR__.'/FileArray.php');

    
# initiate the array Object
    
$fileArrObj = new FileArray();

    
# add to array
    
$fileArrObj[] = "Hello";
         
$fileArrObj[] = "World";

    
// OR

     # add to array
    
$fileArrObj->add( "Hello" );
         
$fileArrObj->add( "World" );
        
    
    
# retrieve from array
    
echo $fileArrObj[0];
          echo
$fileArrObj[1];
   
   
// OR
   
     # retrieve from array
    
echo $fileArrObj->get(0);
        echo
$fileArrObj->get(1);