3v4l.org

run code in 300+ PHP versions simultaneously
<?php function highlight(string $search, string $number) { $searchBegin = NULL; $searchIndex = 0; $search = str_replace([',', '.'], '', $search); foreach (str_split($number) as $numberIndex => $character) { if ($character == $search[$searchIndex]) { if (is_null($searchBegin)) { $searchBegin = $numberIndex; } $searchIndex++; if ($searchIndex == strlen($search)) { return substr($number, 0, $searchBegin) . '<span style="background: yellow">' . substr($number, $searchBegin, $numberIndex - $searchBegin + 1) . '</span>' . substr($number, $numberIndex +1); } } elseif (!in_array($character, [',', '.'])) { $searchBegin = NULL; $searchIndex = 0; } } return $number; } echo highlight('4321', '12,345,678.00') . PHP_EOL; echo highlight('1234', '12,345,678.00') . PHP_EOL; echo highlight('4567', '12,345,678.00') . PHP_EOL; echo highlight('3,456', '12,345,678.00') . PHP_EOL; echo highlight('7.80', '12,345,678.00') . PHP_EOL;
Output for git.master_jit, git.master, rfc.property-hooks
12,345,678.00 <span style="background: yellow">12,34</span>5,678.00 12,3<span style="background: yellow">45,67</span>8.00 12,<span style="background: yellow">345,6</span>78.00 12,345,6<span style="background: yellow">78.0</span>0

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
34.89 ms | 406 KiB | 5 Q