3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function removeVar($url, $key) { $url = preg_replace('/(.*)(?|&)' . $key . '=[^&]+?(&)(.*)/i', '$1$2$4', $url . '&'); $url = substr($url, 0, -1); return $url; } $url = "/search/listing.html?vehicle_type=&year=&make_name=&model_name=&loc_type=3&zipcode=641004&distance=100&make_order=ASC"; $newUrl = removeVar($url, "make_order"); echo $newUrl;
Output for 4.4.9, 5.2.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
/search/listing.html?vehicle_type=&year=&make_name=&model_name=&loc_type=3&zipcode=641004&distance=100
Output for 4.3.11 - 4.4.8, 5.0.0 - 5.2.3
Warning: preg_replace(): Compilation failed: unrecognized character after (? at offset 6 in /in/tjt4I on line 4
Output for 4.3.0 - 4.3.10
Warning: Compilation failed: unrecognized character after (? at offset 6 in /in/tjt4I on line 4