CodeIgniter Forums
Grab URL value... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Grab URL value... (/showthread.php?tid=19056)



Grab URL value... - El Forum - 05-26-2009

[eluser]woomacoder[/eluser]
Hello,

I have a problem; I wanna grab a single part of url, for example:

domain.com/index.php/controller-name/apple-iphone-3g-16gb-black-1

I wanna read in my controller-name, the 1 (ID) of url..., the latest item.
But... i'dont now Sad

Sorry for my english.
Thank you"


Grab URL value... - El Forum - 05-26-2009

[eluser]Dam1an[/eluser]
If you split it up so each part of the item is a seperate URI segment, you can easily grab them using uri->segment

In the current way, you can always get the second segment, which will return "apple-iphone-3g-16gb-black-1" and then explode on the '-' and assuming its always the last part, get the last item in the array


Grab URL value... - El Forum - 05-26-2009

[eluser]woomacoder[/eluser]
Yes, it's a good solution! Thank you damian Wink