RE: [PHP] hard(?) syntax problem

From: Date: Tue, 04 Nov 2003 16:26:36 +0000
Subject: RE: [PHP] hard(?) syntax problem
Groups: php.general 
Request: Send a blank email to php-general+get-168480@lists.php.net to get a copy of this message
On Tuesday, November 04, 2003 8:12 AM Adam wrote: > I want to access a value of an array by key, but the array is not a > variable - it is a constant. > > How do I do it? > I tried > $value = PL_ORT[$key]; > , but this doesn't work (parse error)... > I even tried > $value = {PL_ORT[$key]}; Hi Adam. As per the manual, constants may only evaluate to scalar values. Are you sure what you're trying to do is even possible here? If you try to define a constant as an array, as follows: <?php define('something',array('foo','bar')); ?> the following error results: Warning: Constants may only evaluate to scalar values in c:\phpdev\www\constant.php on line 2. The valid types for use within constants are: - boolean - integer - floating-point number (float) - string Cheers, Pablo

« previous php.general (#168480) next »