Reputation: 5698
I have a very specific question: is the following code possible in one line? Or is there a beter way to do the same?
$key = rand(1,100);
$temp = 'GetObjects'.ucfirst($key).'Array';
$objects = $this->module->$temp();
Like this:
$objects = $this->module->'GetObjects'.ucfirst($key).'Array'();
Upvotes: 0
Views: 281
Reputation: 61567
Maybe
$objects = $this->module->{'GetObjects'.ucfirst($key).'Array'}();
or
$objects = call_user_func(array($this->module, 'GetObjects'.ucfirst($key).'Array'));
Upvotes: 4