Mixing Variable to Function

Sup guys, I can’t remember how I did this before, there is a command I know to do something.

So if I have these two functions:

I want to use a variable for the last part so…

function create($var)

I think if that doesnt work you can do like…
$string = “imageCreateFrom.$var”;
and Use the string as a function: $string()??

PS offtopic: The font thats spose to be monospace on Chrome shows up weird on ubuntu

Awesome thanks guys!!

Call user func was what i was looking for but i like the variable way.

For your help, here is some morning/afternoon motivation:
Eye of the Tiger

[fphp]call_user_func/fphp would be preferred I think. However each of the imagecreatefrom* functions require parameters to be passed, so [fphp]call_user_func_array/fphp would be better suited.

function create_image($type, $args = array()){
  $function = 'imagecreatefrom' . $type;
    return call_user_func_array($function, $args);
  return false;

$image = create_image('jpeg', array('filename.jpg'));

If you’re going to be passing the filename in anyway, you may as well base your decision on which function to use on that. :slight_smile:

What Anthony suggests is a very elegant solution and you should consider that. You can also use your first suggestion, ie a function name as a variable

$createFunction = "imageCreateFrom" . $type;

The function names are all lowercase though, so you should probably watch your casing to avoid issues on linux