Page 1 of 1

read from multiple defines

Posted: Wed Feb 16, 2005 9:44 am
by jakobdoppler
mhhhh

i made some defines with a loop

Code: Select all

for ($i=0; $i<5; $i++) &#123;
			define("_PARAM_EMAIL".$i,"email".$i);
		&#125;
but how can i use a loop to read from these defines ? i tried eval and this version. Must be quite simple, but I can't figure it out :-(

Code: Select all

for ($i=0; $i<5; $i++) &#123;
			echo &#123;_PARAM_EMAIL.$i&#125;;
		&#125;

Posted: Wed Feb 16, 2005 9:52 am
by feyd
constant()

Posted: Wed Feb 16, 2005 11:04 am
by BDKR
Or get_defined_constants()

http://us4.php.net/manual/en/function.g ... stants.php

If you're thinking what I think you're thinking (lol), then

Code: Select all

$costants=get_defined_constants();
foreach($constants&#1111;'user'] as $constant)
    &#123; /* do something with your constant here */ &#125;
Cheers,
BDKR