Skip to content
Advertisement

Sort array by trailing letters [closed]

I have an array like so (generated from an API):

JavaScript

As you can see, some of the entries feature a trailing “L” or “FL”. I would like to sort everything ending with “L” into a group and everything that ends with “FL” into a group and everything else in another group.

Is there any possible way to do this in PHP?

Thank you very much!

Advertisement

Answer

This should be what you are looking for:

JavaScript

The output obviously is:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement