since this is typically a function to be used on all pages in your website, I do not see the big difference in adding
<?php UsersOnline(); ?>
instead of
[[UsersOnline]]
On the other hand, you can always create a droplet that captures the output of the snippet..
<?php
ob_start();
UsersOnline();
$users = ob_get_contents();
ob_end_clean();
return $users;
?>
Note: the dropletcode above is not tested!