3v4l.org

run code in 300+ PHP versions simultaneously
<?php function translatePronouns($text) { static $replacePairs = [ 'iyou' => ['i', 'you'], 'youi' => ['^you', 'i'], 'myyour' => ['my', 'your'], 'yourmy' => ['your', 'my'], 'meyou' => ['me', 'you'], 'youme' => ['you', 'me'], 'myselfyourself' => ['myself', 'yourself'], 'yourselfmyself' => ['yourself', 'myself'], 'mineyours' => ['mine', 'yours'], 'yoursmine' => ['yours', 'mine'], ]; static $expr; if (!isset($expr)) { $parts = []; foreach ($replacePairs as $name => $pair) { $parts[] = "(?<=^|\s)(?P<$name>$pair[0])(?=$|\s)"; } $expr = '#' . implode('|', $parts) . '#i'; } return preg_replace_callback($expr, function($match) use($replacePairs) { foreach ($match as $name => $text) { if ($text !== '' && isset($replacePairs[$name])) { return $replacePairs[$name][1]; } } // var_dump($match); //return $replacePairs[$match[0]]; }, $text); } $strings = [ 'i should go fuck myself', 'i will kill you if i decide it suits me to do so', 'you will eat me', 'my boobs are bigger than yours' ]; foreach ($strings as $string) { echo translatePronouns($string) . "\n"; }
Output for git.master, git.master_jit, rfc.property-hooks
you should go fuck yourself you will kill me if you decide it suits you to do so i will eat you your boobs are bigger than mine

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:
131.94 ms | 405 KiB | 5 Q