SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    str_replace can't find special characters

    I have some text saved in database and i want to replace few srtings in it

    For example i have text in database:

    "√Ėversikt: Hotell Strand Palace √§r bel√§get mitt i Londons centrum"

    I want to repalce "√Ėversikt" with "Hello" using str_replace but it does not work.

    When i echo it shows me: "÷versikt: Hotell Strand Palace √§r bel√§get mitt i Londons centrum"

    It shows me perfect, it should show me like it is being showed but how to using str_replace so that i can replace stings?

    any help please?

    thank you

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    I am not really answering your question directly, and this may not be practical in your case, but did you know you can use a mysql function REPLACE() to replace strings without having to resort to involving PHP at all.

    If you do not use mysql, then I imagine your chosen RDBMS may well have a similar function.

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    What encoding are you using on the database table, and what's the default encoding on your page? (5:1 it doesnt match...)
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  4. #4
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by StarLion View Post
    What encoding are you using on the database table, and what's the default encoding on your page? (5:1 it doesnt match...)
    I am using "Collation: latin1_swedish_ci" in mysql database. what should i use on my php and html page?

  5. #5
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    What does mb_detect_encoding say your string is encoded in?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

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