We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

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


33.8k
  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 . "/")?