?
Solved

PHP - convert %20 back to blank space

Posted on 2013-06-16
3
Medium Priority
?
1,020 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 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

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to count occurrences of each item in an array.
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

743 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