PHP: Last n characters to a specified character in a string? -


i want last n characters string, after last "-" character. like:

$string = "something-123"; $substring = 123; $string2 = "something-253672-something-21"; $substring2 = 21; 

these characters can numbers. how can php? (sorry bad english)

you explode string , parse last element of resulting array:

$splitted = explode("-", $string); $numbers = end($splitted);  if (is_numeric($numbers)) {     echo "yay!"; } else {     echo "nay!"; } 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -