I made a nice solution, here's an example:
<?php
class twitter {
var $v = "Hi";
function tweets($i, $b)
{
return $this->v . $i ."? ". $b;
}
}
$str = "twitter_tweets(5, true)";
$plugin = explode( "_", $str, 2 ); // array( [0] => twitter, [1] = tweets(5, true) )
$func = explode( "(", $plugin[1], 2 ); // array( [0] => tweets, [1] => 5, true) )
$args = substr( $func[1], 0, (strlen($func[1])-1) ); // 5, true
$args = explode( ",", $args ); // array( [0] => 5, [1] => true )
// trim whitespace in arguments
foreach( $args as $key => $val )
{
$args[$key] = trim($val);
}
$$plugin[0] = new $plugin[0]; // $twitter = new twitter
echo call_user_func_array( array( $$plugin[0] , $func[0] ), $args ); // $twitter->tweets(5,true)
?>