Q:

Jump parameter in function

I have a controller in codeigniter called 'Main' with this function:
public function index ($id = false, $filter ='htmlentities') {
    ...
    ...

    }

I want to call it through the URI 'jumping' the first parameter so that it remains 'false':
I would like to be able through the URI using something like:
'main/index/false/myfilter'

However this doesn't work, does anyone know how can I 'jump' this first parameter so that its value remains being false but i am able to change the filter?
(changing parameter order in function is NOT an option)

A:

Just test for the string 'false' at the top of the controller method:
public function index ($id = false, $filter ='htmlentities') {
  if ($id == 'false') {
    $id = false;
  }

  // ...
}

Another possibility might be to use a custom route and simply discard the first parameter. In your app/config/routes.php file, add the rule:
$route['main/index/:filter'] = 'main/index/false/$1';

Now, when you visit 'main/index/myfilter', the $id parameter will be set to false (a string, not a boolean!)

