Stefan83 Posted January 9, 2014 Share Posted January 9, 2014 (edited) HI I'm building a splash page that mobile users are redirected to when they visit a page on my website. from=(Original URI) is added the splash page's URL. There is a link at the bottom of the splash page which gets the value of the 'from' query to allow the user to click back to the orginal page.I'm trying to build a URL for this link with the following script so '?full=1' query string is appended to the end of the URL. Here's the code: <?php $qstring = array('full'=>'1' ); ?> <a href="<?php bloginfo('url'); echo htmlspecialchars($_GET["from"]); ?>?<?php echo http_build_query($qstring) . "\n"; ?>">Continue to Website</a> - get the current URL of a Wordpress site (eg http:www.domain.com)- echo the value of 'from' query (eg from=orginalpage)- and append the full=1The problem is if there is a query string already in the from URI from original page , I get an unwanted duplicate '?' in the URL. So if the original URL is http://www.domain.com/orginalpage/?test=1would redirect tohttp://www.domain.com/splashpage/?from=orginalpage/?test=1So the link looks likehttp://www.domain.com/orginalpage/?test=1?full=1How do I stop the duplicate '?' and replace with '&'?Thanks Edited January 9, 2014 by Stefan83 Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted January 9, 2014 Share Posted January 9, 2014 (edited) You could try <?php // get the query string and parse into an array parse_str($_SERVER['QUERY_STRING'], $queryStringArray); // add full to array $queryStringArray['full'] = 1; // rebuild the query string $queryString = '?' . http_build_query($queryStringArray); ?> <a href="<?php bloginfo('url'); echo $queryString; ?>">Continue to Website</a> Edited January 9, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.