how to iterate over non-English file names in PHP

前端 未结 3 807
忘掉有多难
忘掉有多难 2020-11-27 21:59

I have a directory which contains several files, many of which has non-english name. I am using PHP in Windows 7.

I want to list the filename and their content using

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-27 22:14

    Do discover the files I have this script:

    $content = scandir($directory);
    $list = "\n";
    

    This will succesfully find the file: 鶨鶖鵨鶣鎹鎣 I tried it here on a Linux distro though..

    to read it you use: Line by line:

    $lines = file('file.txt');
    //loop through our array, show HTML source as HTML source; and line numbers too.
    foreach ($lines as $line_num => $line) {
    print "Line #{$line_num} : " . htmlspecialchars($line) . "
    \n";//or try it without the htmlspecialchars }

提交回复
热议问题