|
Posted by Rainman on 12/21/05 01:01
I have an object ($obj) that contains members 'sunday', 'monday',
'tuesday', 'wednesday', etc. I can refer to them in my code as
$obj->sunday, etc. But I want to refer to these members in a loop, such as:
$dow = array('sunday','monday','tuesday',...);
foreach ($dow as $day) {
print $obj->$day;
}
But this syntax does not work. I tried eval() and a few other things
with {}, but all failed.
Can I do this sort of thing? If so, what's the correct syntax?
Mark
[Back to original message]
|