I've written a basic PHP function to convert LFS color coded strings into a string using HTML
tags. See the code below:
Usage:
An example can be seen on my team website. The server color codes are converted using this function: https://www.team-vtec.ga/
<span>
tags. See the code below:
<?php
function lfsColorToHTML($text)
{
$repred = 0;
$repgreen = 0;
$repyellow = 0;
$repblue = 0;
$reppink = 0;
$replightblue = 0;
$repwhite = 0;
$repblack = 0;
$htmlCode = str_replace("^1", "<span style='color:red'>", $text, $repred);
$htmlCode = str_replace("^2", "<span style='color:green'>", $htmlCode, $repgreen);
$htmlCode = str_replace("^3", "<span style='color:yellow'>", $htmlCode, $repyellow);
$htmlCode = str_replace("^4", "<span style='color:blue'>", $htmlCode, $repblue);
$htmlCode = str_replace("^5", "<span style='color:pink'>", $htmlCode, $reppink);
$htmlCode = str_replace("^6", "<span style='color:lightblue'>", $htmlCode, $replightblue);
$htmlCode = str_replace("^7", "<span style='color:white'>", $htmlCode, $repwhite);
$htmlCode = str_replace("^8", "<span style='color:black'>", $htmlCode, $repblack);
$totalrep = $repred+$repgreen+$repyellow+$repblue+$reppink+$replightblue+$repwhite+$repblack;
$repcounter = 0;
while($repcounter < $totalrep)
{
$htmlCode .= "</span>";
$repcounter++;
}
return $htmlCode;
}
?>
<?php
$myString = "^1Hello ^2World. ^3Testing.";
$newString = lfsColorToHTML($myString);
echo $newString; //Result: <span style='color:red'>Hello <span style='color:green'>World. <span style='color:yellow'>Testing.</span></span></span>
?>