Explode a string that contains the route to a file to changes the filename and reconstruct the route
<p>I've a backend that the user selects the route of the file, and I've an input like:</p>

<pre><code>/images/soccer/2010-2011/last_match/image_example.jpg
</code></pre>

<p>Then, with my PHP application I need to change that "image_example" because I encode the name for prevent problems. I split the file name with the last "." to seperate name from extension and then I return the new image name and extension... but I don't know how to identify the route, separate the name, and then rewrite the route.</p>

<p>So the worflow will be like:</p>

<ol>
<li>User inputs the route.</li>
<li>The application identifies the image name.</li>
<li>I call a function than changes the name.</li>
<li>Reconstruct the rotue for the final copy/move.</li>
</ol>

<p>Can anyone help me?</p>

<p>Thank you in advance!</p>
