opendir (), readdir (), how to display file names with an accent?

2

I want to get the names of the files in a folder but at the time of showing them the accented letters appear with a question mark.

How can I make accented letters appear?

I leave the example code.

    <!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <?php
        $directorio = opendir("2015");
        while($archivo = readdir($directorio)){
            if(is_dir($archivo)){
                echo "[".$archivo."]<br/>";
            }
            else{
                echo $archivo."<br/>";
            }
        }
        ?>
    </body>
</html>
    
asked by fernando rojas 15.03.2018 в 23:50
source

1 answer

1

Use utf8_encode to convert the name of the file to the utf8 character system, which is the one you are using in your example:

echo utf8_encode($archivo);

link

    
answered by 16.03.2018 в 00:00