title: Good way to store formatted text in DB to output later
body: <p>I write news for my website and format it like this:</p>
  
  <pre><code>[h1]News[h1]
  [red]Happy New Year[/red]
  [white]Happy New Year[/white]
  </code></pre>
  
  <p>The news are stored as is on the MySQL DB.
  Then when it's called by my website, a function converts every code into HTML format.</p>
  
  <pre><code>[h1][/h1] = &lt;h1&gt;&lt;/h1&gt;
  [red][/red] = &lt;font color=red&gt;&lt;/font&gt;
  </code></pre>
  
  <p>I'm not happy with this method for a long time, but now such codes are obsolet for HTML5.
  Instead of using  I should add it to CSS.</p>
  
  <p>I'm very beginner with PHP, MySQL, CSS, HTML...really, but I'm trying and learning.</p>
  
  <p>So, what I need is the best solution for this matter.</p>
  
  <p>I was thinking to create a CSS rule like:</p>
  
  <pre><code>span.news-red { color=red }
  span.news-white { color=white }
  </code></pre>
  
  <p>And then  them into the code  for red text, etc...</p>
  
  <p>Is this an effective solution or just a palliative?</p>
  
  <p>Thank you.</p>
  
  <h1>EDIT</h1>
  
  <p>I have this two functions to convert format of my text in order to be outputed for the visitor.</p>
  
  <p>1st = Converts [white-text][/white-text] into </p>
  
  <pre><code>$string = preg_replace("/\[white-text\](\S+?)\[\/white-text\]/si","&lt;font color=white&gt;\\1&lt;/font&gt;", $string);
  </code></pre>
  
  <p>2nd - Converts [url][/url] into </p>
  
  <pre><code>$string = preg_replace("/\[url\](\S+?)\[\/url\]/si","&lt;a href=\"http://\\1\" target=\"_blank\"&gt;\\1&lt;/a&gt;", $string);
  </code></pre>
  
  <p>Problems:
  WHITE-TEXT - It only changes the color of one word phrases.</p>
  
  <p>URL - It works fine, but I would like to be able to write anything in the readable part of the URL.</p>