CodeIgniter Forums

Full Version: Codeigniter, linking to dynamic URLS
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
All my routing is done with a database so my urls are dynamic.
However, i would still like to be able to link to them, but to do that, I need your help.

Currently my routes look like this:
Code:
Array
(
    [default_controller] => user/create
    [404_override] =>
    [create/success] => user/create/success
    [create] => user/create
    [administrator] => administrator/dashboard
    [login] => user/login
    [logout] => user/logout
    [administrator/editor] => administrator/editor
    [administrator/clients] => administrator/clients
    [administrator/client/(:num)] => administrator/clients/client/$1
)

I'm looking to create a function where i input the link to the controller.
It could be:
Code:
echo url_real('administrator/clients/client/11'); // returns: administrator/client/11

My theory is that i first match the varible with all the array's values, and after that, matches all the $1, $2, $3 with the array's keys.
And after that return the dynamic url.