PHP:奇怪的字符导致了file()函数中数组的第一个索引


PHP: Strange character resulting in the first index of array from file() function

可能重复:
如何从文件开头删除ï»?

我怀疑这个问题以前也遇到过,但我还找不到任何关于它的信息。我试过用各种方式编辑文件,但每次我在第一个条目中都会出现这个奇怪的字符。

所以我有一个文本文件(.txt(,其中包括:

drw

billy,william

gary,橡树

现在,我调用file((函数,然后像这样打印:

<?php 
// read the file into an array called $users
$users = file('C:/private/filetest_02.txt');
?>
<pre>
<?php print_r($users); ?>
</pre>

但是,然后我收到这个输出:

阵列

(

[0] =>  derek, drw
[1] => billy, william
[2] => gary, oaktree 

)

为什么这个字符显示在数组的第一个条目中?我能做些什么来缓解这种情况?提前感谢任何能对这个问题有所了解的人。

这是一个UTF-8字节顺序标记。

您需要修改文件才能将其删除。