Hola,

para generar URLs que tienen tildes, eñes y espacios sugiero hacer esto:

//le cambio los espacios ,los tildes y las ñ.
$url_nueva = str_replace(array(" ","á","é","í","ó","ú","Á","É","Í","Ó","Ú","ñ","Ñ"),
array("%20","%E1","%E9","%ED","%F3","%FA","%C1","%C9","%CD","%D3","%DA","%F1","%D1"),
$url_vieja_con_tildes);

espero que sirva.

byp.

    --Written all by myself! Using my Spanish knowledge!!!

    Apesadumbrado, yo hablo muy poco espanol.

    Hablas ingles?

    -o-

    --Written by auto-computer-translator
    Apesadumbrado, pero yo hable solamente un poco español.

    ¿Usted habla inglés?

      yes I do.

      You write spanish better than the computer!!

        Thanks, I love to hear that even though I only passed Spanish up to 9th grade!! What did the computer's translation say?

        Ok, I got off topic. Could you translate your original post (and code?) into English?

          the script replace some characters that are used in spanish with the equivalent characters that are allowed in URL.

          for example this link will not work:

          <a href='./files/canción en español.txt'> link to canción</a>

          but this will work:

          <a href='./files/canci%F3n%20en%20espa%F1ol.txt'> link to canción</a>

          the conjugation of the verb "hablar" that the auto translator puts is bad, he puts "hable", you put "hablo" and that's rigth. the rest of the phrase is well in both cases.

            OK, now I understand the code a bit better. But in your str_replace, you have the first key of the array as "" -> "%20". %20 is a space, so wouldn't it be " " -> "%20"? In any case, now that I understand, what is the problem?

            So at least I can still conjugate -ar verbs! I always sucked at the -ir verbs, past tense. "Viviste"?

              yes, it should be a space instead of an empty string.
              sorry it was a typing problem.

                Ok...still, what is the problem? Or is it resolved? I'm so confused! Adios mio! (I probably spelled that way off!)

                  no, there is no problem, I put that in here only for information, because I spend some time looking for solution and this would help someone else.

                  I should not have puted that in here?
                  If I shouldn't i'm sorry.

                  I don't know how to put RESOLVED in the thread.

                    It looks like you solved it...RESOVLED is in the thread! In future cases, you might want to post stuff like that under "Code Critique"...or maybe the mods should create a new category for helpful "code snippets" like this...at least there's no problem this time! 😃

                      Write a Reply...