Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Uri::last();
  • I think having Uri::last(); would be really useful. what do you think guys?
  • I'd say there's a point where it all becomes clutter, PHP has pretty good functions for working with arrays. The following would do fine for me:
    $segments = Uri::segments();
    $end = end($segments);
    

    What I might agree with, is to allow something like this:
    $end = Uri::segment(-1); // count from the end backwards
    

    But we all got our plates pretty full, code it up and pull-request if you want/need it...
  • Thanks Jelmer for your thoughts on this, I agree we have to be careful not to clutter the framework. I'll do a pull request and add the method when I get some time. Thanks
  • +1 for the -1 approach as this fits in with how PHP does things. Otherwise $last = end(Uri::segments()) is really not that much to ask for. We don't want to get the reputation of having a method for EVERYTHING, as core PHP does this stuff just as well.
  • ok, let's leave it out and go with Uri:Segment(-1);

Howdy, Stranger!

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

In this Discussion