On 12-May-2004 René Fournier wrote:
> Hi,
> 
> I have two questions involving Constants.
> 
> 1. I want to refer to a refer to a Constant by its value (which is 
> unique), and return its name. E.g.,:
> 
>       define ("SEND_DS","1");
>       define ("SEND_DS_ACK","2");
>       define ("RESEND_DS","3");
>       define ("STARTUP_DS","12");
> 
> For example, if I receive "3", I would like to echo "RESEND_DS"--the 
> name of the constant. Is there a simply way to do this? Or am I
> better 
> using an Associative Array (which is what I was thinking)? Then I
> could 
> such refer to an element by its key or value (both of which are 
> unique). 

Both.

get_defined_constants()
array_flip()

Regards,

-- 
Don Read                                     [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to 
   steal the neighbor's newspaper, that's the time to do it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to