I have a url : http://localhost:8888/projects/oop/2
http://localhost:8888/projects/oop/2
I want to access the first segment --> projects
projects
I\'ve tried
An easy way to get the first or last segment, in case you are unsure of the path length.
$segments = request()->segments(); $last = end($segments); $first = reset($segments);