I need to split a string in PHP by \"-\" and get the last part.
So from this:
abc-123-xyz-789
I expect to get
You can use array_pop combined with explode
Code:
$string = 'abc-123-xyz-789'; $output = array_pop(explode("-",$string)); echo $output;
DEMO: Click here