3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function doIt(string $line): string { $pos = strrpos($line, "&gt;"); if ($pos === false) { return $line; } if ($pos < 4 || substr($line, $pos - 4, 8) === "&gt;&gt;") { return $line; } return substr_replace($line, '<p style="color:#0f0;">', $pos, 0) . "</p>"; } function doItMultiline(string $owo): string { return implode(array_map('doIt', explode(PHP_EOL, $owo)), PHP_EOL); } $line = "awoo&gt;&gt;owo &gt;blyat lolis"; $line2 = "awoo&gt;&gt;owo"; var_dump(doItMultiline($line)); var_dump(doItMultiline($line2));
based on l8LJZ
Output for hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.2.6
string(58) "awoo&gt;&gt;owo <p style="color:#0f0;">&gt;blyat</p> lolis" string(15) "awoo&gt;&gt;owo"
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected ':', expecting '{' in /in/3b7gi on line 3
Process exited with code 255.