Re: strange foreach behaviour

From: Date: Tue, 05 Aug 2003 12:03:22 +0000
Subject: Re: strange foreach behaviour
Groups: php.general 
Request: Send a blank email to php-general+get-158265@lists.php.net to get a copy of this message
My apologies for the last post - somehow managed to send whilst attempting to copy and paste... d'oh. I'd like to try again. I have come up against a very strange problem. I currently have no idea how to even approach attempting to fix it... In the following code snippet, $this->items is an array of objects - each of these objects is one of two object types (with similar interfaces). There is nothing that unusual in the these few lines: foreach ($this->items as $code => $item) { var_dump($this->items[$code]); var_dump($item); etc. } but after successfully calling this piece of code a number of times in my application, I get the following output: object(citem)(2) { ["q"]=> int(1) ["c"]=> string(3) "157" } NULL Fatal error: Call to a member function on a non-object in /var/www/local/ge/include/product.php4 on line 58 I have no comprehension how it is that the two var_dump() commands can produce different outputs. Can anyone suggest what sort of thing I need to be looking at?! Any help very gratefully received, regards, Martin

« previous php.general (#158265) next »