Location: PHPKode > scripts > Simple Enumeration > simple-enumeration/SimpleEnum.class.php
class SimpleEnum{
	var $aList;
	function SimpleEnum($aItems){
			$this->aList = array_flip($aItems);
			die('Only allow array to construct SimpleEnum.');

	//Return the value of specific enum
	function is($item){
		if(array_key_exists($item, $this->aList)){
			return $this->aList[$item];
				Using 'die' because I would like to have programmer's attention
				on referring a wrong item.
			die('No such item in SimpleEnum: '.$item);	
	//Return the total length of enum
	function length(){
		return count($this->aList);
	//Return all the enum array values
	function values(){
		return $this->aList;
	//Print all enum array values
	function printValues(){
		print '<pre>';print_r($this->aList); print '</pre>';

Return current item: Simple Enumeration