You can use a regular expression:
;
$pattern = '/(.*)\/.*\.php?/';
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
?>
See: http://php.net/manual/en/function.preg-match.php
Edit:
Sorry, i thought you had a string you want to modify.