Jump to content

Recommended Posts

hello. I need some help here.

 

I have dynamic variable that contains characters separated by blank spaces. I need to replace the blank space (%20) with a plus(+) sign) wherever it occurs.

For example, my variable  $label might contain

$label=one word.

when i echo $label it prints one%20word. I would like to print it as one+word.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/242795-php-converting-blank-spaces-to-symbol/
Share on other sites

That's pretty much why I asked. %20 is really only used in urls. If you are manually setting that, you are making more work for yourself. You should use urlencode on variables when sending them to the browser.

 

http://php.net/manual/en/function.urlencode.php

 

Then if you need to decode a url: http://www.php.net/manual/en/function.urldecode.php

 

Although for the most part you shouldn't ever have to use urldecode.

 

Example of urlencode:

 

<?php
   $variable=urlencode("my variable data & info");
   echo "<a href=\"url.php?variable={$variable}\">Go!</a>";
?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.