3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php // Everything you enter here will be executed by our servers. Try it! $uri = "?sort%5B%5D=1&str%5B%5D=4&curs%5B%5D=1&page=2&page=1&page=2&page=5&page=4&page=3&page=2&page=1&page=1&page=1&page=1&page=1&page=1&page=1&page=1&page=1&page=1&page=1&tesdsd=2"; function ggp($url) { // get GET-parameters string preg_match('/^([^?]+)(\?.*?)?(#.*)?$/', $url, $matches); $gp = (isset($matches[2])) ? $matches[2] : ''; return $gp; } function deleted($url) { // get GET-parameters string $res = preg_match("/([?&])$page=.*?(?=&|#|\z)/", $url, $matches); return array($res,$matches); } echo ggp($uri); echo"<br>"; var_dump(deleted($uri)); $string = 'April 15, 2003'; $pattern = '/(\w+) (\d+), (\d+)/i'; $replacement = '${1}1,$3'; echo preg_replace($pattern, $replacement, $string); echo preg_replace("/&page=/", "YPA", $uri);
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
<br> Notice: Undefined variable: page in /in/hbq0J on line 12 array(2) { [0]=> int(0) [1]=> array(0) { } } April1,2003?sort%5B%5D=1&str%5B%5D=4&curs%5B%5D=1YPA2YPA1YPA2YPA5YPA4YPA3YPA2YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1&tesdsd=2
Output for 4.3.0 - 5.0.3
<br> Notice: Undefined variable: page in /in/hbq0J on line 12 array(2) { [0]=> int(0) [1]=> array(0) { } } April1,2003?sort%5B%5D=1&str%5B%5D=4&curs%5B%5D=1YPA2YPA1YPA2YPA5YPA4YPA3YPA2YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1YPA1&tesdsd=2