3v4l.org

run code in 300+ PHP versions simultaneously
<?php $search = 'The'; $replace = 'A'; $subject = "The Quick Brown Fox Jumps Over The Lazy Dog's Thermos!"; function str_rreplace($search, $replace, $subject) { return (false !== $pos = strrpos($subject, $search)) ? substr_replace($subject, $replace, $pos, strlen($search)) : $subject; } function preg_rreplace($search, $replace, $subject) { preg_match_all($search, $subject, $matches, PREG_SET_ORDER); return ($lastMatch = end($matches)) ? str_rreplace($lastMatch[0], $replace, $subject) : $subject; } echo str_rreplace($search, $replace, $subject) . "\n---\n" . preg_rreplace($search, $replace, $subject);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: preg_match_all(): Delimiter must not be alphanumeric, backslash, or NUL in /in/lNU8R on line 12 Fatal error: Uncaught TypeError: end(): Argument #1 ($array) must be of type array, null given in /in/lNU8R:13 Stack trace: #0 /in/lNU8R(13): end(NULL) #1 /in/lNU8R(18): preg_rreplace('The', 'A', 'The Quick Brown...') #2 {main} thrown in /in/lNU8R on line 13
Process exited with code 255.

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:
59.59 ms | 401 KiB | 8 Q