PHP Classes

File: Example.php

Recommend this page to a friend!
  Classes of Martin Lacroix   Simple Array   Example.php   Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Short example
Class: Simple Array
Manage arrays with keys of any type
Author: By
Last change:
Date: 12 years ago
Size: 410 bytes
 

Contents

Class file image Download
<?php
include 'SimpleArray.php';

$a = new SimpleArray();
$a['123.456'] = 'string'; // the key is a string
$a[123.456] = 'float'; // the key is a float
$a[] = 'value'; // standard definition

// it's impossible to walk through it using foreach or each
// The right way is :
$a->rewind();
while(
$a->valid()) {
  
// do some stuff using $a->key() and $a->current()
  
$a->next();
}