Stuck on characters with accents, file_get_contents, regex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • theduffman
    New Member
    • Mar 2008
    • 1

    Stuck on characters with accents, file_get_contents, regex

    Hi, I'm trying to write code to update nightly some NHL stats. Everything works, except for names with an accent, e.g. José Théodore. This won't generate a match no matter what I try. I've edited the code to show the relevant pieces. What I use:

    [PHP]
    $data = file_get_conten ts('http://avalanche.nhl.c om/team/app?service=pag e&page=Stats' );

    $regex = '/'.str_replace(" ", "\s", $row2['name']).'<\/a>\n<\/td>...........
    preg_match($reg ex, $data, $match);


    [/PHP]

    I've tried changing the field's character encoding to utf8_general_ci . I've also tried to run a strtr on the pulled page, but doing an echo on it shows no change. I've also tried using the name with and without accents in my database.

    How can I get this to work? I can't get a match when using accents.
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Use mb_ereg_match.

    Comment

    Working...