3v4l.org

run code in 300+ PHP versions simultaneously
<?php //this code will append a &mobileapp to every url ob_start(function($buffer){ $append = 'mobileapp'; $domain = '(?:'.preg_quote('example.com/~hillybilly') .'|'. '(?.*?\.)?'.preg_quote('foobar.com') .')'; $buffer = //str_replace('example.com/~mydir/', 'w00t', $buffer);// preg_replace('/\b(https?:\/\/'.$domain.')([a-z0-9\._\/\~%\-\+&\#!=\(\)@]*)?([?])?([a-z0-9\._\/\~%\-\+&\#!=\(\)@]*)?/im', '$1$2?'.$append.'&$4', $buffer); $regex = '/\b(https?:\/\/'.$domain .'\/?)([a-z0-9\._\/~%\-\+&\#!=\(\)@]*)?([?])?([a-z0-9\._\/~%\-\+&\#!=\(\)@]*)?/igm'; $buffer = preg_replace($regex, '$1$2?'.$append.'&$4', $buffer); return $buffer; }); ?> http://foobar.com http://www.example.com/~hillybilly/foobar.php

preferences:
44.76 ms | 402 KiB | 5 Q