manipulating constant name as string

From: Date: Sun, 01 Jan 2006 18:37:17 +0000
Subject: manipulating constant name as string
Groups: php.general 
Request: Send a blank email to php-general+get-228072@lists.php.net to get a copy of this message
Hello I am trying to access the constant name as string and not the constant contents. For example, define('myconst', 'const text 1'); $myArray = array() myArray['myconst'] = "this is it" etc. $xmltext=""; foreach ($myArray as $key => $val) { echo "$key = $val\n\n"; $xmltext .= "$xmltext = $xmltext . "<$key> $val </$key>"; } Unfortunately, $key within the string concatenation is translated into the constant value. However, for the echo statement, then $key constant name is displayed. Is there a way to keep the constant name rather its value when manipulating it as a string? thanks, Daniel

« previous php.general (#228072) next »