is there a way to use explode function to explode only by last delimiter occurrence?
$string = "one_two_ ... _three_four"; $explodeResultArray = e
For such a taks, you can just use strstr and strrchr:
$valueBeforeLastUnderscore = rtrim(strrev(strstr(strrev($value), '_')), '_'); $valueAfterLastUnderscore = ltrim(strrchr($value, '_'), '_');
That being said, I like the regular expression answer more.