Hi,
I am making use of a reference to an array of objects in a foreach loop. I think I am missing something. I keep getting the following warning:
I am aware that warnings can be ignored, but I thought if I can eliminate them, its better for my code.Code:Invalid argument supplied for foreach()
As an example, consider:
Any help on how I can eliminate the warning will be most appreciated!PHP Code:
//getObjectArray() retrieves an array of objects
$objArr = &getObjectArray();
foreach($objArr as $obj)//warning generated here
{
echo "Name:" . $obj->name;
echo "Surnam:". $obj->surname;
}
tino



Reply With Quote




. I also agree on var_dump, xdebug, print_r etc...invaluable debugging tools!


Bookmarks