Excuse me for my bad description of what I am looking to learn. I am new on coding sites.
I am trying to colorize the results of a variable. If the value is bigger than zero then color should be red.
My code is the following:
$content="
<h2>---3 HH and 3 LL FIBO--- </h2>
<code>
<pre>".htmlspecialchars(file_get_contents("$path/$file"))."</pre>
</code>";
echo $content;
And the result is something like this:
Balance | Equity | Used Mr | Usable Mr, % |
38.610,21 | 65.781,67 | 19.900,00 | 69,75 |
Symbol |Amount|S/B| P/L | Gross P/L |
EUR/CAD | 500 | S | 201,2 | 7.687,34 |
Is it possible to color the numbers if they are bigger than zero? Any ideas?
You can appy a preg_replace on your content to check for numbers and wrap it around for exemple!
$regex = '/((?!0)\d+((\.|\,)\d+)*)/';
$content="
<h2>---3 HH and 3 LL FIBO--- </h2>
<code>
<pre>".preg_replace($regex, '<span class="color-red">$1</span>', htmlspecialchars(file_get_contents("$path/$file")))."</pre>
</code>";
echo $content;
(Haven't tested but might work)