|
Posted by Ridge Burner on 05/19/06 17:40
I have seen this done before, but I can't remember the specifics nor any
keywords really to Google it. Hopefully someone can point me in the right
direction.
I want to use a parameter in custom function to determine what pre-defined
function to call to manipulate some text.
<?php
$string = "hello world";
function change_text($string,$mode='NORMAL'){
if($mode != 'NORMAL'){
return $mode($string); //$mode should become the name of
the function I want to call to manipulate the text
}else{
return $string;
}
}
//Some examples of what I want
echo change_text($string); // return hello world
echo change_text($string,'ucwords'); // return Hello World
echo change_text($string,'strtoupper'); // return HELLO WORLD
echo change_text($string,'strtolower'); // return hello world
echo change_text($string,'ucfirst'); // return Hello world
?>
Thanks in advance for any help you can offer!
--Ridge
Navigation:
[Reply to this message]
|