Highlight the text string in HTML CSS with php : <p>I'm looking for a quick way to highlight a text string if it has a flag i.e.(-R) as a first symbol in it, from the beginning till the line end (\n).</p>

<p>The function will be given a text of a multiple strings separated with "\n" that may or may not contain any flags at all. Something like this:</p>

<pre><code>-Rnotes to be red
-Ynotes to be yellow
-G notes to be green
</code></pre>

<p>In the output of this function I need to get this:</p>

<pre><code>&lt;span style="background-color:red"&gt;notes to be red&lt;/span&gt;
&lt;span style="background-color:yellow"&gt;notes to be yellow&lt;/span&gt;
&lt;span style="background-color:green"&gt; notes to be green&lt;/span&gt;
</code></pre>
