title: Need help replacing & with &amp;
body: <p>I have no idea why I'm not able replace <code>&amp;</code> with <code>&amp;amp;</code></p>
  
  <p>This is my string: <code>/Designers/batlak&amp;selvig.jpg</code>.  </p>
  
  <p>This is what I've tried so far:</p>
  
  <pre><code>$image = preg_replace("#(&amp;(?!amp;))#U",'&amp;amp;',$brand['image']);
  $image = str_replace('&amp;','&amp;amp;',$brand['image']);
  $image = htmlspecialchars($brand['image']);
  $image = mysql_real_escape_string($brand['image']);
  $image = urlencode($brand['image']); // This works, but image will not show
  $image = rawurlencode($brand['image']);  // This works, but image will not show
  </code></pre>
  
  <p>Any suggestions?</p>
  
  <p><strong>update</strong></p>
  
  <p>Yes, it's a part of an image url used by the <code>&lt;img&gt;</code> tag.<br>
  <code>urlencode</code> does not work - the image tag does not understand the format.</p>
  
  <p>This is the error I get at W3C Validator:  </p>
  
  <pre><code>Validation Output: 1 Error 
  Line 84, Column 104: &amp; did not start a character reference. 
  (&amp; probably should have been escaped as &amp;amp;.)
  </code></pre>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>This is how I'm testing it:</p>
  
  <pre><code>&lt;?php 
     $image = str_replace('&amp;','&amp;amp;',$brand['image']); 
     echo $image; 
  ?&gt;
  </code></pre>
  
  <p><strong>Output:</strong><br>
  <code>/Designers/batlak&amp;selvig.jpg</code></p>
  
  <p>I've also tested replacing <code>$brand['image']</code> with <code>/Designers/batlak&amp;selvig.jpg</code></p>