3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re ='/(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/im'; $str = 'Test text http://hello-world.com Test text http://google.com/file.jpg?google=1 Test text https://hell.o.wor.ld/test?qwe=qwe Test text text text http://test.test/test hello all how are you I hope you all are fine '; $utmUrl = "utm_source=source&utm_medium=email&utm_campaign=mycamp"; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); foreach ($matches as $match) $str = preg_replace('%' . $match[0] . '%', $match[0] . (strpos($match[0], '?') !== false ? '&' : '?') . $utmUrl, $str); var_dump($str);
Output for 7.2.0 - 7.2.34, 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
string(323) "Test text http://hello-world.com?utm_source=source&utm_medium=email&utm_campaign=mycamp Test text http://google.com/file.jpg?google=1 Test text https://hell.o.wor.ld/test?qwe=qwe Test text text text http://test.test/test?utm_source=source&utm_medium=email&utm_campaign=mycamp hello all how are you I hope you all are fine "
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 string(323) "Test text http://hello-world.com?utm_source=source&utm_medium=email&utm_campaign=mycamp Test text http://google.com/file.jpg?google=1 Test text https://hell.o.wor.ld/test?qwe=qwe Test text text text http://test.test/test?utm_source=source&utm_medium=email&utm_campaign=mycamp hello all how are you I hope you all are fine "

preferences:
136.27 ms | 402 KiB | 191 Q