<?php function replaceFileName($input, $newFileName) { $info = pathInfo($input); return $info['dirname'] . DIRECTORY_SEPARATOR . $newFileName . '.' . $info['extension']; } $test = "/txt/txt/txt/txt.txt"; var_dump(replaceFileName($test, 'testing'));
You have javascript disabled. You will not be able to edit any code.