3v4l.org

run code in 300+ PHP versions simultaneously
<?php $expression = "/(?J)\b(?: (?<obj>i)(?:(?<part>'m)|\s(?<part>am|was))? |(?<obj>you|they)(?:(?<part>'re)|\s(?<part>are|were))? |(?<obj>it|he|she)(?:(?<part>'s)|\s(?<part>is|was))? |(?<obj>(my|your|it)sel(f|ves)) )\b/uix"; $message = "that you are not who you think you're but I'm not myself either"; echo $output = preg_replace_callback($expression, function ($matches){ $o = ''; $object = strtolower($matches['obj']); switch($object){ case 'i': $o = 'you'; break; case 'you': $o = 'I'; break; case 'yourself': $o = 'myself'; break; case 'myself': $o = 'yourself'; break; default: $o = $object; } if(isset($matches['part'])){ switch($part = strtolower($matches['part'])){ case "'re": case "are": if($object == 'you') $o .= ' am'; break; case 'am': $o .= ' are'; break; case "'m": $o .= "'re"; break; case 'was': if(!in_array($object, ['he','she','it'])) $o .= ' were'; break; case 'were': if($object == 'you') $o .= ' was'; break; } } return $o; }, $message );
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
that I am not who I think I am but you're not yourself either
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 that I am not who I think I am but you're not yourself either

preferences:
239.97 ms | 402 KiB | 291 Q