3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Remove a query string parameter from an URL. * * @param string $url * @param string $varname * * @return string */ function removeQueryStringParameter($url, $varname) { $parsedUrl = parse_url($url); $query = array(); if (isset($parsedUrl['query'])) { parse_str($parsedUrl['query'], $query); unset($query[$varname]); } $path = isset($parsedUrl['path']) ? $parsedUrl['path'] : ''; $query = !empty($query) ? '?'. http_build_query($query) : ''; return $parsedUrl['scheme']. '://'. $parsedUrl['host']. $path. $query; } $urls = array( 'http://www.example.com?test=test', 'http://www.example.com?bar=foo&test=test2&foo2=dooh', 'http://www.example.com', 'http://www.example.com?foo=bar', 'http://www.example.com/test/no-empty-path/?foo=bar&test=test5', 'https://www.example.com/test/test.test?test=test6', ); foreach ($urls as $url) { echo $url.PHP_EOL; echo removeQueryStringParameter($url, 'test'). PHP_EOL. PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
http://www.example.com?test=test http://www.example.com http://www.example.com?bar=foo&test=test2&foo2=dooh http://www.example.com?bar=foo&foo2=dooh http://www.example.com http://www.example.com http://www.example.com?foo=bar http://www.example.com?foo=bar http://www.example.com/test/no-empty-path/?foo=bar&test=test5 http://www.example.com/test/no-empty-path/?foo=bar https://www.example.com/test/test.test?test=test6 https://www.example.com/test/test.test

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
69 ms | 406 KiB | 5 Q