How to fill empty spaces in strings so the variables can be used in a url

It is for static page, dynamic page, website, SEO, performance and other web development discussion
ramverma
Posts: 435
Joined: Sat Aug 23, 2014 5:34 pm
Contact:

How to fill empty spaces in strings so the variables can be used in a url

Postby ramverma » Sat Sep 12, 2015 10:27 am

Hey,

I need to file in any gap in a string with %20 so i can pass the variable into a url as at the moment it just passes the first word in. For exmaple

I use these Get functions to collect the ID, date1 and date2 from the url thats is being passed over

[PHP]
PHP Code:
$ID = $_GET['ID'];
$date1 = $_GET['Date1'];
$date2 = $_GET['Date2'];
Then i created a new url variables which contains the second part of my url with the pulled in variables

PHP Code:
$url = "?ID=$ID&Startdate=$date1&Finishdate=$date2";
however when i echo $url it reads :
PHP Code:
?ID=test ID&Startdate=2015-05-12&Finishdate=2015-05-12
So when i add $ur to my url ("http://localhost/test/Certificates.php".$url); it reads out as

http://localhost/test/Certificates.p...ate=2015-08-27.

as it is only taking the first word in the string, so i need to find a way of adding %20 to any spaces which are in ID so the outcome would be

http://localhost/test/Certificates.p...ate=2015-08-27.

Hope this makes sense, IF not just drop me a comment and i will try to clear it up (first time poster please be nice )


Return to “PHP, HTML, MYSQL and Web Hosting”

Who is online

Users browsing this forum: No registered users and 1 guest