preg_match using "ñ"

Discussion in 'PHP' started by userman, Aug 20, 2010.

  1. #1
    Hi,

    I am using:
    if ( !preg_match("/^[0-9 a-z A-Z.ñÑ]+$/",$_POST['country']) ) {die (header( 'Location: invalid?country' ));}

    I want add "ñÑ" for the contry Spain / España but this dont work.
    Why?

    Regards.
     
    userman, Aug 20, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    Maybe use...

    
    $country = str_replace('Spain', 'España', $_POST['country']);
    
    
    PHP:
    EDIT: thats all you need right ?
     
    Last edited: Aug 21, 2010
    MyVodaFone, Aug 21, 2010 IP
  3. userman

    userman Active Member

    Messages:
    158
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Thanks MyVodaFone.

    Yes, invalid?country is a valid location.

    I fix it with:

    if ( !eregi("^[a-zA-ZáéíóúÁÉÍÓÚñÑ 0-9 ,._]",$_POST...
    PHP:
    Regards.
     
    userman, Aug 21, 2010 IP