Ir para conteúdo
Fórum Script Brasil
  • 0

Funsao Que Tira Os Acentos Da Palavra


Titio Linkin

Pergunta

Posts Recomendados

  • 0

Eu fiz a um tempão veja:

$REMOVE_ACENTOS = "$VARIAVEL ";

$REMOVE_ACENTOS = str_replace( "à", "a", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "á", "a", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "â", "a", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ã", "a", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ä", "a", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "è", "e", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "é", "e", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ê", "e", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ë", "e", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ì", "i", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "í", "i", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "î", "i", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ï", "i", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ò", "o", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ó", "o", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ô", "o", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "õ", "o", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ö", "o", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ù", "u", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ú", "u", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "û", "u", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ü", "u", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "À", "A", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Á", "A", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Â", "A", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ã", "A", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ä", "A", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "È", "E", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "É", "E", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ê", "E", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ë", "E", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ì", "I", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Í", "I", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Î", "I", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ï", "I", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ò", "O", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ó", "O", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ô", "O", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Õ", "O", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ö", "O", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ù", "U", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ú", "U", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Û", "U", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ü", "U", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "ç", "c", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "Ç", "C", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "não", "n", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "não", "N", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "´", "", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "`", "", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "¨", "", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "^", "", $REMOVE_ACENTOS);

$REMOVE_ACENTOS = str_replace( "~", "", $REMOVE_ACENTOS);

$VARIAVEL = "$REMOVE_ACENTOS";

$VARIAVEL - você substitue pela váriavel que você está usando!!

Mais você pode usar a função "ereg_replace".

$REMOVE_ACENTOS = ereg_replace( "[àáâãä]", "a", $REMOVE_ACENTOS);

Ai é só seguir a lógica. ;)

Link para o comentário
Compartilhar em outros sites

  • 0

Galéra é que assim:

Tenho um sistema onde os membros da equipe escrevem tutorial ai fiz um editor HTML visual em PHP ai tem la o botao pra ir visualizando pra ver como ta ficando ai fiz os bbcode e tal ai quandot iver tudo pronto ele gera um arquivo html do servidor e já link para o site.....

Mais o nome do arquivo pra não ficar repetido eu fiz um O TITUTLO DO TUTORIAL + RAND ai juntou o titutlo do tutorial mais um rand que eu fiz....

mais o titulo os caras as vezes botam acentos ou seja então quero fazer 2 titulos um para ir pro site e outropra criar o arquivo e não estou conseguindo tirar os acentos fdps :angry:

Mas ae ajudem ai vlw.. ;)

Link para o comentário
Compartilhar em outros sites

  • 0
Desculpa ai professor de portugues prometo não desapontalo mais com os meus erros de portugues ok.

<_< ...

Agora voltando ao assunto.....

ae cara é que sei la não da dando certo

E qual seria o problema de usar um str_replace só no Nome que vai pro arquivo!?
:huh:

Você não precisa fazer o replace nos dois...precisa só na parte que vai entrar pro nome do arquivo...

Exemplo:

$titulo = "Desapontá-lo";

$nome_arquivo = strtolower(stripAccents($titulo));

Ali em cima a função em azul corresponde àquela enviada pelo Gladisson...

Dá pra ser assim ou tem algum impedimento no seu script?

Link para o comentário
Compartilhar em outros sites

  • 0

Ok...ele não fez uma função...

Vou fazer uma função pra facilitar a sua vida... ^_^

function stripAccents($target){

$tempvar = strtolower($target);

$tempvar = str_replace( "à", "a", $tempvar);

$tempvar = str_replace( "á", "a", $tempvar);

$tempvar = str_replace( "â", "a", $tempvar);

$tempvar = str_replace( "ã", "a", $tempvar);

$tempvar = str_replace( "ä", "a", $tempvar);

$tempvar = str_replace( "è", "e", $tempvar);

$tempvar = str_replace( "é", "e", $tempvar);

$tempvar = str_replace( "ê", "e", $tempvar);

$tempvar = str_replace( "ë", "e", $tempvar);

$tempvar = str_replace( "ì", "i", $tempvar);

$tempvar = str_replace( "í", "i", $tempvar);

$tempvar = str_replace( "î", "i", $tempvar);

$tempvar = str_replace( "ï", "i", $tempvar);

$tempvar = str_replace( "ò", "o", $tempvar);

$tempvar = str_replace( "ó", "o", $tempvar);

$tempvar = str_replace( "ô", "o", $tempvar);

$tempvar = str_replace( "õ", "o", $tempvar);

$tempvar = str_replace( "ö", "o", $tempvar);

$tempvar = str_replace( "ù", "u", $tempvar);

$tempvar = str_replace( "ú", "u", $tempvar);

$tempvar = str_replace( "û", "u", $tempvar);

$tempvar = str_replace( "ü", "u", $tempvar);

$tempvar = str_replace( "ç", "c", $tempvar);

$tempvar = str_replace( "não", "n", $tempvar);

$tempvar = str_replace( "´", "", $tempvar);

$tempvar = str_replace( "`", "", $tempvar);

$tempvar = str_replace( "¨", "", $tempvar);

$tempvar = str_replace( "^", "", $tempvar);

$tempvar = str_replace( "~", "", $tempvar);

$target = $tempvar;

return $target;

}

Agora é usar:
$arquivo = stripAccents($titulo);

Clique aqui para ver um exemplo...

Sem aquele strtolower() que eu tinha posto antes... coloquei ele dentro da função agora... ^_^

Era isso!?

Link para o comentário
Compartilhar em outros sites

  • 0
Ele não usou expressões regulares...:mellow:

Entre no exemplo e veja como está funcionando, cara... pode ir... B)

é o de expressoes regulares só funcionou com o A oia

$novotitulo = str_replace( "[àáâãä]", "a", $titulo);

$novotitulo = str_replace( "[èéê]", "e", $titulo);

$novotitulo = str_replace( "[íìÏî]", "i", $titulo);

$novotitulo = str_replace( "[óòôõ]", "o", $titulo);

$novotitulo = str_replace( "[úùû]", "u", $titulo);

$novotitulo = str_replace( "[não]", "n", $titulo);

$novotitulo = str_replace( "[ç]", "c", $titulo);

$novotitulo = str_replace( "[´`¨^~]", "", $titulo);

com o resto não funfo

Link para o comentário
Compartilhar em outros sites

  • 0

Viu como o meu exemplo estava funcionando! ^_^

function stripAccents($target){

  $tempvar = strtolower($target);

  $tempvar = str_replace( "à", "a", $tempvar);

  $tempvar = str_replace( "á", "a", $tempvar);

  $tempvar = str_replace( "â", "a", $tempvar);

  $tempvar = str_replace( "ã", "a", $tempvar);

  $tempvar = str_replace( "ä", "a", $tempvar);

  $tempvar = str_replace( "è", "e", $tempvar);

  $tempvar = str_replace( "é", "e", $tempvar);

  $tempvar = str_replace( "ê", "e", $tempvar);

  $tempvar = str_replace( "ë", "e", $tempvar);

  $tempvar = str_replace( "ì", "i", $tempvar);

  $tempvar = str_replace( "í", "i", $tempvar);

  $tempvar = str_replace( "î", "i", $tempvar);

  $tempvar = str_replace( "ï", "i", $tempvar);

  $tempvar = str_replace( "ò", "o", $tempvar);

  $tempvar = str_replace( "ó", "o", $tempvar);

  $tempvar = str_replace( "ô", "o", $tempvar);

  $tempvar = str_replace( "õ", "o", $tempvar);

  $tempvar = str_replace( "ö", "o", $tempvar);

  $tempvar = str_replace( "ù", "u", $tempvar);

  $tempvar = str_replace( "ú", "u", $tempvar);

  $tempvar = str_replace( "û", "u", $tempvar);

  $tempvar = str_replace( "ü", "u", $tempvar);

  $tempvar = str_replace( "ç", "c", $tempvar);

  $tempvar = str_replace( "não", "n", $tempvar);

  $tempvar = str_replace( "´", "", $tempvar);

  $tempvar = str_replace( "`", "", $tempvar);

  $tempvar = str_replace( "¨", "", $tempvar);

  $tempvar = str_replace( "^", "", $tempvar);

  $tempvar = str_replace( "~", "", $tempvar);

  $target = $tempvar;

  return $target;

}  // function stripAccents

$titulo = $_POST[title];

$arquivo = stripAccents($titulo).".ext";

Ese é o código...

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,1k
    • Posts
      651,8k
×
×
  • Criar Novo...