RE: [PHP] How to cast objects in arrays.
| From: | Martin Towell | Date: | Fri, 05 Jul 2002 06:19:44 +0000 |
| Subject: | RE: [PHP] How to cast objects in arrays. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-105571@lists.php.net to get a copy of this message | ||
don't try to cast... it should just return an object of type IvActivity
assuming $this->getRow($row) returns an object of type IvActivity in the
first place
-----Original Message-----
From: Anas Mughal [mailto:anasmughal@yahoo.com]
Sent: Friday, July 05, 2002 4:18 PM
To: php-general@lists.php.net
Subject: [PHP] How to cast objects in arrays.
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php