3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function nct_modifier_merge_url_args($url, $new_arguments) { if(empty($url)) { return $url; } $adjusted = FALSE; // workaround for https://php.net/manual/en/function.parse-url.php#example-4524 if (PHP_VERSION_ID <= 50407 && substr($url, 0, 2) == '//') { $url = 'http:' . $url; $adjusted = TRUE; } $parsed_url = parse_url($url); if ($adjusted) { unset($parsed_url['scheme']); } parse_str((isset($parsed_url['query'])?$parsed_url['query']:''), $args); parse_str($new_arguments,$newargs); $args = array_merge($args,$newargs); $query = ''; if(count($args)) { foreach ($args as $k => $v) { $query .= urlencode($k).'='.urlencode($v).'&'; } $query = substr($query, 0, -1); } if (!isset($parsed_url['scheme'])) { $url = '//'; } else { $url = $parsed_url['scheme'] . '://'; } $url .= ((isset($parsed_url['host']) && $parsed_url['host'])?$parsed_url['host']:$_SERVER['SERVER_NAME']). ((isset($parsed_url['path']) && $parsed_url['path'])?$parsed_url['path']:'/'). ($query?'?'.$query:''). ((isset($parsed_url['fragment']) && $parsed_url['fragment'])?'#'.$parsed_url['fragment']:''); return $url; } echo nct_modifier_merge_url_args('//zpravy.aktualne.cz/?utm_source=centrumHP&utm_medium=dynamicleadbox','channel_id=hot_searches-HPA&hot=1&client_id=centrum-atlas-ssfs');
Output for 5.2.7 - 7.2.0
//zpravy.aktualne.cz/?utm_source=centrumHP&utm_medium=dynamicleadbox&channel_id=hot_searches-HPA&hot=1&client_id=centrum-atlas-ssfs
Output for 4.3.0 - 5.2.6
Notice: Use of undefined constant PHP_VERSION_ID - assumed 'PHP_VERSION_ID' in /in/lG0YA on line 11 //zpravy.aktualne.cz/?utm_source=centrumHP&utm_medium=dynamicleadbox&channel_id=hot_searches-HPA&hot=1&client_id=centrum-atlas-ssfs