PDA

View Full Version : How do I convert %20 into a space with PHP code?


AJR
Wed 5th Sep '01, 5:20am
I am trying to store a value in a table like "Wonder%20Woman". I'm doing this because there are images with spaces associated with the value (Wonder Woman.gif).

So I'll have this string:
$image="<img src=\"image[name].gif\" border=\"0\" alt=\"$name2\">

where image[name] will be 'Wonder%20Woman'

The $name2 needs to be 'Wonder Woman' for the alt tag. Anyone know how to do this? Any help is appreciated!

Mark Hensler
Wed 5th Sep '01, 12:47pm
<?
$name2 = str_replace("%20"," ",$name2);
?>

or

<?
$name2 = urldecode($name2);
?>

Read more here: urldecode() (http://php.net/manual/en/function.urldecode.php), str_replace() (http://php.net/manual/en/function.str-replace.php)

AJR
Wed 5th Sep '01, 2:39pm
Thank you Max for the quick response! This will help me accomplish my task!