Reply to referring to an object member

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация