This is a relatively straightforward implementation of a PHP Map that uses associative PHP array as data storage. custom research paper
require_once('ig/util/AbstractMap.class.php'); /** * Map that uses an associative array. * * @author Ivan Georgiev */ class ig_util_AssocMap extends ig_util_AbstractMap { var $data = array(); /** * @return ig_util_AbstractMap */ function & Create() { $map =& new ig_util_AssocMap(); return $map; } function clear() { $this->data = array(); } function containsKey($key) { return array_key_exists($key, $this->data); } function & get($key) { if ($this->containsKey($key)) $value =& $this->data[$key]; else $value = false; return $value; } function isEmpty() { return empty($this->data); } function keyArray() { return array_keys($this->data); } function put($key, &$value) { $this->data[$key] =& $value; } function remove($key) { if ($this->containsKey($key)) unset($this->data[$key]); } function size() { return count($this->data); } }
See also: Unit tests for PHP Map implementation with associative array, Abstract key-value Map in PHP