title: Edit String in PHP before being added
body: <p>I have a system that writes a XML file.</p>
  
  <p>The problem is that I cannot have in the XML file this symbol <code>&amp;</code></p>
  
  <p>I need to replace this symbol wherever it is find in the code with <code>&amp;amp;</code></p>
  
  <p>The problem is I have a LOT of strings, and I do not want to apply a function that will replace that symbol for EVERY SINGLE string I have.</p>
  
  <p>This is an example:</p>
  
  <pre><code>$stringData ="&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n";
  $stringData .="&lt;ingrooves_import xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:schemaLocation=\"http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd\" schema_version=\"1\" schema_revision=\"0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://schemas.ingrooves.com/INgrooves/INgroovesImport_1_0.xsd\"&gt;\n";
  $stringData .= "&lt;album&gt;\n";
  $stringData .= "&lt;title&gt;".$albumTitle."&lt;/title&gt;\n";
  $stringData .= "&lt;label_reference&gt;LA0001&lt;/label_reference&gt;\n";
  $stringData .= "&lt;performer&gt;".$MainArtist."&lt;/performer&gt;\n";
  $stringData .= "&lt;catalog_number&gt;".$CatalogueNumber."&lt;/catalog_number&gt;\n";
  $stringData .= "&lt;upc&gt;".$UPC_EAN_JAN."&lt;/upc&gt;\n";
  $stringData .= "&lt;release_date&gt;".$releaseDate."&lt;/release_date&gt;\n";
  $stringData .= "&lt;copyright&gt;".$DigiDistYear."&lt;/copyright&gt;\n";
  </code></pre>
  
  <p>And I have many more of $stringData in my code. So you can understand I do not want to apply for every $stringData a code that will replace that symbol.</p>
  
  <p>I want to find a way to tell to the code, that for any $stringData variable, and for any content this $stringData will encounter, then it must replace <code>&amp;</code> with <code>&amp;amp;</code></p>
  
  <p>Is there a way of doing it?</p>
  
  <p>In few words, the code should do so:</p>
  
  <p>For every content you are going to encounter inside the variable $stringData, from now on, you should change <code>&amp;</code> with <code>&amp;amp;</code> everytime you encounter this symbol.</p>
  
  <p>Please help me!</p>
  
  <p>Thanks</p>