Built into CI is the ability to call site_url() these ways:
site_url('products/view/123'); // or
site_url(array('products', 'view', 123));
But I wanted to write them this way:
site_url('products', 'view', 12); // or
site_url('products/view', 123); // or
site_url('products/view', 123, $another_variable);
So I wrote me some code:
APP/helpers/MY_url_helper.php:
function site_url($uri = '')
{
if (func_num_args() > 1) {
$args = func_get_args();
$uri = implode('/', $args);
}
$CI = get_instance();
return $CI->config->site_url($uri);
}