I'm trying to see if there's a way to create functions from array values.
I have an array of database table names:
Array
(
[0] => table1
[1] => table2
[2] => table3
[3] => table4
[4] => table5
)
etc... I want to be able to produce a function with each of the table names:
public function table1()
{
// function code here...
}
public function table2()
{
// function code here...
}
The code in each function will be the same for now. Just trying to get the function created every time a new table is added to the database.
Thanks!
Each function will look something like this when done:
public function tablename()
{
$obj = new obj();
$obj->set_table('tablename');
$this->_output_view($obj->render());
}
call_user_funcis the right for you.function __call()instead of actually trying to create functions.