Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

replacing a space with + in a string

BBeennBBeenn Member Posts: 44
Hello,
In my PHP script I am making a link for the user to follow which is sent out by e-mail. It contains some of their information. I make the link using:

here

However, when it comes to a space which was entered into the name field it gets confused as it is suposted to have a + where the spaces are.
Could someone please help me make it add + inpace of spaces.
Thanks
BBeenn

Comments

  • SouldrinkerSouldrinker Member Posts: 143
    you could try to replace every " " to a "+"?

    Otherwise you have to use the htmlentities function that is build in in php, just check out the syntax at http://www.php.net/manual/en/function.htmlentities.php

    hope I unterstood your problem right

    best regards,

    sebastian mohrenstecher
    executive secretary
    net::allies

    www.net-allies.de
    [email protected]

  • BBeennBBeenn Member Posts: 44
    Hello,
    I think you understood me. Looking at the like you gave it lookes like it should make it work, however it doesn't change anything. I have tried spaces, , , etc and it changes none of them.

    The line to make the variable is:

    $clickhere2 = htmlentities("http://www.mysite.com/mail/news/subscribeconf.php?address=$address&username=$username&version=$version");


    To make the link I use:

    here


    What comes out the the e-mail that is sent out is:

    here


    As you can see it does not change the spaces.
    If you or anyone else could help, that would be great.
    Thanks
  • jeskejeske Member Posts: 23
    : Hello,
    : In my PHP script I am making a link for the user to follow which is sent out by e-mail. It contains some of their information. I make the link using:
    :
    : here
    :
    : However, when it comes to a space which was entered into the name field it gets confused as it is suposted to have a + where the spaces are.
    : Could someone please help me make it add + inpace of spaces.
    : Thanks
    : BBeenn
    :
    Hi,
    Have you tried using ereg_replace?

    $variableURL = "address=$address&username=$username&version=$version";
    $withpluses = ereg_replace(" ","+",$variableURL);
    $finalAddress = "here";

    Hope this helps.

    Jeff
  • willeewillee Member Posts: 2
    : Could someone please help me make it add + inpace of spaces.

    It sounds to me like you want to make use of the PHP function, "urlencode".

    You can find the syntax at http://www.zend.com/manual/function.urlencode.php.


  • Andre YoungAndre Young USAMember Posts: 0

    __ ( http://forcoder.org ) free ebooks and video tutorials about ( Swift Go Visual Basic .NET PL/SQL Scratch Python PHP Java Delphi C Visual Basic MATLAB Assembly R JavaScript Perl C# Objective-C Ruby C++ Scala FoxPro Ada Lisp F# ML Dart Rust Prolog SAS Lua Hack Alice ABAP COBOL Scheme D LabVIEW Clojure Kotlin Julia Fortran Erlang Transact-SQL Apex Awk Logo VBScript Crystal Bash ) _________

Sign In or Register to comment.