[eluser]Boyz26[/eluser]
Hi everyone,
Is there any way I can convert a string variable to a function?
I am storing a series of actions in the database that will be called later.
Code:
function recipe($id) {
$this->db->where('recipe_id', $id);
$query = $this->db->get('actions');
foreach($query->result() as $row):
//my question: can I do any of these?
$actionName = $row->actionName;
$this->$actionName();
//or..
convertToFunction($actionName);
//or..
if($actionName == 'fryAnEgg') { $this->fryAnEgg() }
elseif($actionName== 'bakeCookie') { $this->bakeCookie() }
//and so on..
endforeach;
}
function fryAnEgg() {
//complex function
}
function bakeCookie() {
//another function
}
I will be having many many actions, so I don't want to make a long elseif list..
Thank you!!