/ Published in: PHP

use an object as an array
Expand |
Embed | Plain Text
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() { return $this->current() !== false; } /* * to use Countable */ { } }
You need to login to post a comment.