replace urlpath in php
<p>I am new to php.</p>

<p>I am getting default image path as \xampp\htdocs\Sample\tmp/one.jpg</p>

<p>and i have to replace \xampp\htdocs with http:\localhost </p>

<p>If i use in this way i am getting required output</p>

<pre><code>$absolute = "\xampp\htdocs";
$relative = "http:\\localhost";
$imagepathurl = "\xampp\htdocs\Sample\tmp\/safety-masks_5092610ad4f3f.jpg";

echo str_replace($absolute,$relative,$imagepathurl);
</code></pre>

<p>But i am getting the $imagepathurl from database. If i use this in same formate i am not getting result</p>

<pre><code>$absolute = "\xampp\htdocs";
$relative = "http:\\localhost";

$imagepathurl = '"'.$imagepath.'"';
echo str_replace($absolute,$relative,$imagepathurl);
</code></pre>
