PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
jakobdoppler
Forum Commoner
Posts: 46 Joined: Wed May 21, 2003 6:16 pm
Post
by jakobdoppler » Wed Feb 16, 2005 9:44 am
mhhhh
i made some defines with a loop
Code: Select all
for ($i=0; $i<5; $i++) {
define("_PARAM_EMAIL".$i,"email".$i);
}
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++) {
echo {_PARAM_EMAIL.$i};
}
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Feb 16, 2005 9:52 am
constant()
BDKR
DevNet Resident
Posts: 1207 Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:
Post
by BDKR » Wed Feb 16, 2005 11:04 am
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ї'user'] as $constant)
{ /* do something with your constant here */ }
Cheers,
BDKR