I have a configuration array that looks like:

var $allowed_states = 
  array(
    "startup",
    "null",
    "waiting_user_bleh",
    "processing_user_drek"
    .. blah ..
    .. blah ..
  );

I don't want the programmer to have to know anything except the starting
'state' is
always going to be the first one listed, and they won't have to number
them.

But then, I have a public function, 'function SetEvent( $name="" )' that
needs to look in that array and find that $name'ed state. 
No problem, walk the array, you say! (me too) But what I'd like to find
is a function that is faster than a loop I could code that would give me
the numeric index to that state.

Any ideas anybody? I'm kinda asking for an array that could be addressed
either by its key or it's value and return the opposite. The I could go:

if(!isset(access_by_value($this->allowed_states)) blah;

or, index into another array  using the numeric value (faster) like so:

functions_to_execute =
state_event_response[access_by_value($this->allowed_states)];

I could always a secondary associative array if necessary, I 'spose.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to