I think you misunderstand the
limit
parameter off the
explode[
^] function. It is used to limit the number off element to be returned by the
explode
function and all remaining part are stored in the last string.
If you had used this
$str = 'one/two/three/four';
$arr = explode('/', $str, 2);
the result will be
one
two/three/four
and with this
$str = 'one/two/three/four';
$arr = explode('/', $str, 3);
the result will be
one
two
three/four
I found this
How to Explode String Right to Left?[
^] and based on it you can use:
$str = 'one/two/three';
$arr = array_map('strrev', explode('/', strrev($str), 2));
I have not tested it, so you need to see if it works.