Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Routing with regex
  • Could somebody give me an example route with a regex used? I didn't see any in the docs and wanted to see how it was done. Thanks.
  • Route parsing uses a preg_replace(), so any valid regex for that function will do. You do not need to specify the delimiters, and you can use the normal regex placeholders ($1 etc) on the righthand side of the route definition...
  • How do I reference the match string within my controller as a param? For example:
    '[A-Z]{5}' => 'home/test', Thanks
  • If you want to use the match, you need to enclose it in brackets, like with any regex. You can then append it to the URI like so: '([A-Z]{5})' => 'home/test/$1'. In your controller, you'll use Uri::segment(3) to fetch the first parameter.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion