Convert accents, & ordm, and spaces to hyphens

0

I have an upload system from which to upload a file with this type of nomenclature:

  

Law 4,472 - 2015 - Amends Law 4,000 of July 10, 2013 -   Particular Archive.pdf

I'm removing the spaces and accents as follows:

$arquivo = $_FILES["Arquivo"]['name'];
$extensao = pathinfo($arquivo);
$extensao = $extensao['extension'];
list($nomeArquivo,$extensaoArquivo) = explode(".".$extensao,$arquivo);
$novoNome = strtolower( preg_replace("[^a-zA-Z0-9-.]", "-", strtr(utf8_decode(trim($nomeArquivo)), utf8_decode("áàãâéêíóôõúüñçÁÀÃÂÉÊÍÓÔÕÚÜÑÇ."), "aaaaeeiooouuncAAAAEEIOOOUUNC-")) );
$arquivo $novoNome.".".$extensao;

But when the file has º , the ? sign appears. How can I fix this by making this sign also hyphenated?

    
asked by anonymous 03.01.2018 / 19:01

1 answer

0

I did it that way and it looks like it worked, but if it's wrong, you can fix it:

$novoNome = strtolower( preg_replace("[^a-zA-Z0-9-|\.]", "-", strtr(utf8_decode(trim($nomeArquivo)), utf8_decode("áàãâéêíóôõúüñçÁÀÃÂÉÊÍÓÔÕÚÜÑǺ."), "aaaaeeiooouuncAAAAEEIOOOUUNC-")) );
    
03.01.2018 / 19:10