I have created function
function do_stuff($text) {
$new_text = nl2br($text);
return $new_text;
}
$result = do_stuff("Hello \n World!");
//returns "Hello <br /> World!"
I want to be able to supply another simple built in PHP function e.g. strtoupper() inside my function somehow, its not just strtoupper() that i need, i need ability to supply different functions into my do_stuff() function.
Say i want to do something like this.
$result = do_stuff("Hello \n World!", "strtolower()");
//returns "Hello <br /> World!"
How would i make this work without creating another function.
function do_stuff($text, $sub_function='') {
$new_text = nl2br($text);
$sub_function($new_text);
return $new_text;
}
$result = do_stuff("Hello \n World!");
//returns "Hello <br /> World!"
P.S. Just remembered variable variables, and googled, there's actually is Variable functions too, might answer this one myself.