Skip to content
Advertisement

PHP Parsing Getting the latest value from a string using a delimiter

I have a question which relates to PHP. Is there any way to just grab the last string using a delimiter? For example, to put you in perspective, I want to grab the lastest content from the / from every string.

JavaScript

How could I using PHP cut the whole string and get only the latest value. The output would be something like:

JavaScript

I have tried regex but I am not very good at it,

MY CODE:

JavaScript

Here the $varPretty[-1] should return red.

  • ANOTHER SOLUTION IS:
JavaScript

Advertisement

Answer

Please try this method will work for you:

JavaScript

Output should be like:

important

enter image description here

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