[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

PHP - convert %20 back to blank space

Posted on 2013-06-16
3
Medium Priority
?
1,069 Views
Last Modified: 2013-06-16
Hi,
how do I convert %20 back to an actual space?

From

$myvar = 'myweb.com/225/About_Our_Shopping_Cart/LINK%20Online%20Shop';

to

$myvar = 'myweb.com/225/About_Our_Shopping_Cart/LINK Online Shop';

Open in new window

0
Comment
Question by:sabecs
3 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 1000 total points
ID: 39252155
You could use 'str_replace' but the question is why would you want to?  Actual spaces can cause problems in URLs and that is the normal way to handle that.  Web servers normally convert %20 to a plain space anyway.  I always remove spaces from directory and file names.

http://php.net/manual/en/function.str-replace.php
0
 
LVL 12

Assisted Solution

by:sivagnanam chandrakanth
sivagnanam chandrakanth earned 1000 total points
ID: 39252178
use urlencode http://php.net/manual/en/function.urlencode.php

$myvar = urlencode('myweb.com/225/About_Our_Shopping_Cart/LINK%20Online%20Shop');
0
 

Author Comment

by:sabecs
ID: 39252200
Thanks for your feedback, reason to remove them is because I pass URL to a another page and process the link.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month19 days, 5 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question