There is no magic. First, prepare a list of dictionary that match all possible folder or file names to their desirable new names, in PHP, use associative array, e.g.
$newnames = array("oldname1"=>"newname1", "oldname2"=>"newname2")
then, in the code of your, replace the appropriate
echo $parts[$j]
, depending on whether it is for descriptive purpose for for actual href link, with
echo $newnames[$parts[$j]]
You will have to figure it out based on your requirement. Of course, make sure the $parts values are included as keys in the $newnames.
Reference:
PHP 5 Arrays[
^]