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

Variable Variable

I am trying to find out if Phalcon supports variable variables or dynamic evaluation? The code below shows the basic sof what I am trying to do.

//This sets $story_prefix to "home"

$story_prefix =     lower($story["story_name"]);    

// This is the desired end result. Setting the view variable home_title to the returned firld from the database loop. 

// The word home below would actually be the $story_prefix variable from above.



Got it! Below for those interested.

$story_variable = $this->story_prefix."_title";

$this->view->$story_variable = $story["story_title"];