Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2010
    Posts
    105
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Question I need help with preg_match

    Hey!

    I have an form on my website that i would to change three letters to html-format instead of the swedish letters. Is that possible? It should be very simple only sanitazing or changing those letter into another expression, when the form is submitted.

    The letter is = and here what i want them to change to.

    = å
    = ä
    = ö

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You mean these are entered into a text input and provided to PHP? Then yes, you can use htmlentities to convert these.
    PHP Code:
    $str '  ';

    print 
    htmlentities($strENT_COMPAT'UTF-8'); 

  • #3
    Regular Coder
    Join Date
    Jan 2010
    Posts
    105
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Yes exactly. But sorry im really newbie at php, should there not be a section when the code starts?

    something like: <? CODE ?>

    And will this make that changes into an &aring;? How can it recognize wich form it should make the changes for? And should it be in the head section ?

    Thanks in advise.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Quote Originally Posted by Haidar View Post
    Yes exactly. But sorry im really newbie at php, should there not be a section when the code starts?

    something like: <? CODE ?>

    And will this make that changes into an &aring;? How can it recognize wich form it should make the changes for? And should it be in the head section ?

    Thanks in advise.
    It goes wherever you want to print it out. The $str is simply the source, if it comes from a post field you can find it in a $_POST offset.

  • #5
    Regular Coder
    Join Date
    Jan 2010
    Posts
    105
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Excuse me but it would be REALLY nice if you could show me this in some sample of a html page. I would really really persiut that, so i know the strucutre. It dosnt have to be an hard sample, just an easy html test-page so i can see where the code should stick and so.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Writing an HTML page will have no benefit as you cannot see the processing code.
    All that matters is that how you print it out is wrapped in entities:
    PHP Code:
    $str '  ';
    $entities htmlentities($strENT_COMPAT'UTF-8');

    print 
    "
    <div>
        <p>The following are special characters: $entities</p>
    </div>
    "

    Results in a simple:
    Code:
    <div>
        <p>The following are special characters: &aring; &auml; &ouml;</p>
    </div>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •