CodeIgniter Forums
Codeigniter, linking to dynamic URLS - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Codeigniter, linking to dynamic URLS (/thread-60887.html)



Codeigniter, linking to dynamic URLS - El Forum - 07-21-2014

[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.