php - ArrayObject::getIterator error -


this how trying apartments name database, getting er error. how trying apartments names

$userapt = $user->getapartments()->getiterator();  while ($userapt->valid()) {   echo  ($userapt->key() . ' => ' . $userapt->current()) . "\n";      $userapt->next(); }  $useraptname = $user->getapartment()->getiterator();  while ($useraptname->valid()) {     ($useraptname->key() . ' => ' . var_dump($useraptname->current()) . "\n");     $useraptname->next(); } 

running this, following error:

catchable fatal error: object of class mybundle\entity\userapartment not converted string 500 internal server error - contexterrorexception

how can error fixed?
in advance!

you trying echo object

echo ($userapt->key() . ' => ' . $userapt->current()) . "\n";

you can solve implementing public function __tostring() {} method in userapartament class. in way when try echo $user->current() use __tostring() method show string value of object.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -