The FSM package provides a simple class that implements a Finite State Machine. WWW: http://pear.php.net/package/FSM/