At controller I want to use add data in foreach

foreach ($photos as $photo){ $this->view->setVar("addGenre",$photo->genre); $addGenre .= $photo->genre."/"; // 1. here occur some problem $i++; }

upper line $addGenre .=  <== I want to use this method. but error 

Undefined variable addGenre
$this->view->setVar("addGenre",$photo->genre); 
or
$this->view->setVar("genre",$addGenre); 

used it 
but ...no way..

please help me... thanks


18.6k
  1. Rewrite better the post, it's hard to read.
  2. You are setting a view variable, not a normal variable. they are totally different.
  3. Aren't you looking for $this->view->setVar("addGenre", $photo->genre . "/")?