title: Preg_replace_all links to markdown format
body: <p>We're converting to markdown, before we used an 'in-house' system, where both the image links and all data with it (e.g. alt) in another bracket.</p>
  
  <p>For example <code>{IMAGE LINK}[OPTIONAL ALT WITH OTHER DATA]</code></p>
  
  <p>Now we are moving to markdown, (our data is stored as markdown in the database), I need to convert everything into markdown:</p>
  
  <p>So How can I turn all instances of <code>{LINK}[OPTIONAL DATA]</code> (square brackets not required, so some are just {}) into markdown equivalent: </p>
  
  <p>Basically, </p>
  
  <p><code>{http://www.youtube.com/image.gif}[this
   is optional alt]</code> INTO
   <code>![alt](http://www.youtube.com/Image.gif)</code></p>
  
  <p>I have the following so far, but do I deal with the optional [ALT DATA] tag?</p>
  
  <pre><code>   if (preg_match_all('/\[(.*?)\]/i', $string, $matches, PREG_SET_ORDER)) 
     {
  
  
     }
  </code></pre>