title: PHP - How can regex replace a string by condition
body: <p>I have a string: </p>
  
  <pre><code>{include "abc"}
  
  {literal} 
  
  function xyz() {
  
         "ok";
  
     }
  
  {/literal}
  
  {abc}
  
  {123 }
  </code></pre>
  
  <p>I just want to replace all <code>{</code> to <code>{{</code> and <code>}</code> to <code>}}</code> not in <code>{literal}</code> tag. The result will be: </p>
  
  <pre><code>{{include "abc"}}
  
  {{literal}}
  
     function xyz() {
  
         "ok";
  
     }
  
     //... something contain { and }
  
  {{/literal}}
  
  {{abc}}
  
  {123 }}
  </code></pre>
  
  <p>Someone can help me, Thanks</p>