/ Published in: PHP
use an object as an array
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
class array_test implements ArrayAccess, Iterator, Countable { public function __construct() {} /* * to use ArrayAccess */ public function offsetSet($offset,$value) { if ($offset == "") { $this->container[] = $value; } else { $this->container[$offset] = $value; } } /* * to use ArrayAccess */ public function offsetExists($offset) { } /* * to use ArrayAccess */ public function offsetUnset($offset) { } /* * to use ArrayAccess */ public function offsetGet($offset) { } /* * to use Iterator */ { } /* * to use Iterator */ { } /* * to use Iterator */ { } /* * to use Iterator */ { } /* * to use Iterator */ public function valid() { } /* * to use Countable */ { } }