I am, for fun, trying to make it able to give an array some options and then implode the array into a string which can be used with the WideImage class. But I am having troubles. It’s like it’s actually not possible.
My code is following:
$options = array('resize'=>'50,50');
$actions = implode('->', $options);
$img = WideImage::load($image) . $actions . ';';
This would make a string like:
WideImage::load('../images/photo.jpg')->resize(50,50);
What I am searching for from you guys, is to tell me if this is possible at all.
UPDATE
When I am using eval() I am getting an error that the methods given to the wideimage class is undefined property.
Here is my code:
$actions = 'resize(50,50)';
return eval('WideImage::load($image)->$actions->saveToFile('path/to/file')');
This gives me an error of undefined property, and says that saveToFile() is member of a non-object. But if I hardcode the resize and don’t use $actions it’s actually working. What am I doing wrong here?
call_user_func_array is perfect for this, but you would need to refactor a few things.