PHP Casting as Object type in foreach Loop
- by Coulton
Within the following code, $quiz_object->personalities contains an array of Personality() objects.
// Loop through each personality that exists for the quiz
foreach($quiz_object->personalities AS $existing_personality)
{
// Show all of the existing personalities
echo $existing_personality->GetQuizMakerPersonalityHTML();
}
How do I "cast" (I think that's the right word) my variable $existing_personality within the foreach loop as the object type?
I wish to do this so that when I type $existing_personality->, I get the list of public functions available for that object type.
At the moment, Zend doesn't know that it refers to a Personality object within the loop.