How to cast objects in arrays.
| From: | Anas Mughal | Date: | Fri, 05 Jul 2002 06:17:45 +0000 |
| Subject: | How to cast objects in arrays. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105570@lists.php.net to get a copy of this message | ||
I have a function getRow() that returns a new instance
of an object called IvActivity. I insert this new
instance into $list. I need to call getTitle method on
each of the inserted objects. However, I keep on
getting parse error on the line that does the casting.
Please help.
$i = 0;
while ($row = mysql_fetch_array($mysql_result)) {
$instance = $this->getRow($row);
$list[$i] = $intance;
$i++;
}
// ...
foreach ($list as $item) {
$act = (IvActivity) $item;
echo "item: " . $act->getTitle();
}
(I also tried simple for loop with $list[$i] logic.
Unf, I am not able to cast those objects either.)
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com