title: Replace " with \", only if enclosed by "
body: <p>I'm reading a string from my database for which json_encode doesn't work. (Using PHP)</p>
  
  <p>I need to replace all occurrences of <code>"</code> with <code>\"</code>, but only if the occurrence is already enclosed by <code>"</code>.</p>
  
  <p>Sample string:</p>
  
  <pre><code>{"val1": "This is "some value" that is inside of the "string" and such", "val2": "And here is yet another "value" that is messed up by quotation marks", "val3": "etc. etc."}
  </code></pre>
  
  <p>Should be changed into:</p>
  
  <pre><code>{"val1": "This is \"some value\" that is inside of the \"string\" and such", "val2": "And here is yet another \"value\" that is messed up by quotation marks", "val3": "etc. etc."}
  </code></pre>