foreach with an array reference (objects)
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.
Invalid argument supplied for foreach()
As an example, consider:
Any help on how I can eliminate the warning will be most appreciated!
//getObjectArray() retrieves an array of objects
$objArr = &getObjectArray();
foreach($objArr as $obj)//warning generated here
echo "Name:" . $obj->name;
echo "Surnam:". $obj->surname;