So, I have a code like this:
Code: Select all
$str = '/one/two/three/four/five/six';//sometimes this can have more the end, such as /seven/eight/ but not always
$pieces = explode('/', $str);
$wantedPiece = $pieces[4];//equals "four" which is the piece I want
Code: Select all
$wantedPiece = array_pop(array_pop(explode('/', $str, 6)));//if array_pop returned the remaining array instead of the last element this would work...