3v4l.org

run code in 300+ PHP versions simultaneously
<?php $find = array( '/\^0(.*?)\^/', '/\^1(.*?)\^/', '/\^2(.*?)\^/', '/\^3(.*?)\^/', '/\^4(.*?)\^/', '/\^5(.*?)\^/', '/\^6(.*?)\^/', '/\^7(.*?)\^/', '/\^8(.*?)\^/', '/\^9(.*?)\^/', ); $replace = array( '<font color="#000000">$1</font>^', '<font color="#F65A5A">$1</font>^', '<font color="#00F100">$1</font>^', '<font color="#EFEE04">$1</font>^', '<font color="#0F04E8">$1</font>^', '<font color="#04E8E7">$1</font>^', '<font color="#F75AF6">$1</font>^', '<font color="#FFFFFF">$1</font>^', '<font color="#7E7E7E">$1</font>^', '<font color="#6E3C3C">$1</font>^', ); // Just a Random Test String $aDemoString = "^3THE^7::^5MODERN^2WARFARE^7::^3Server^7"; $namefix = preg_replace($find, $replace, $aDemoString); echo $namefix;
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
<font color="#EFEE04">THE</font><font color="#FFFFFF">::<font color="#04E8E7">MODERN<font color="#00F100">WARFARE</font></font></font>^7::<font color="#EFEE04">Server</font>^7

preferences:
249.02 ms | 406 KiB | 349 Q