Solved

PHP - convert %20 back to blank space

Posted on 2013-06-16
3
971 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 83

Accepted Solution

by:
Dave Baldwin earned 250 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 250 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
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.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

717 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