1.txt文本文件中的一行文本:
2000|抑制|Inhibition|||①接受刺激后,组织或机体活动减弱或变为相对静止.焦虑和精神恍惚会使身体机能减化,导致抑制.是与兴奋相反的生理现象.②也作抑止.压制;控制.|||to restrain; to control; to check; to contain; to govern; to suppress; to bottle sth. up; to bring (or get) sth. under control; to fight sth. back (or down); to hold sth. back|张三|2008-10-15 09:46:12
$handle=fopen("1.txt","r");
$data=fgetcsv($handle,1024,"|");
$num=count($data);
print_r($data);结果:Array ( [0] => 2000 [1] => 抑制 [2] => Inhibition [3] => [4] => [5] => ①接受刺激后,组织或机体活动减弱或变为相对静止.焦虑和精神恍惚会使身体机能减化,导致抑制.是与兴奋相反的生理现象.②也作抑止.压制;控制. [6] => [7] => [8] => to restrain; to control; to check; to contain; to govern; to suppress; to bottle sth. up; to bring (or get) sth. under control; to fight sth. back (or down); to hold sth. back [9] => 张三|2008-10-15 09:46:12 [10] => ) 为什么是这样的,为什么时间不在第十个单元里。
Array ( [0] => 2000 [1] => 抑制 [2] => Inhibition [3] => [4] => [5] => ①接受刺激后,组织或机体活动减弱或变为相对静止.焦虑和精神恍惚会使身体机能减化,导致抑制.是与兴奋相反的生理现象.②也作抑止.压制;控制. [6] => [7] => [8] => to restrain; to control; to check; to contain; to govern; to suppress; to bottle sth. up; to bring (or get) sth. under control; to fight sth. back (or down); to hold sth. back [9] => 张三 [10] =>2008-10-15 09:46:12 ) 

解决方案 »

  1.   

    如果这个复制到文本文件中是没有错误的,可是这些数据是我从数据库中导到文本文件中,并且文本文件的编码是UTF-8的 就有问题了!!上面的我今天重新执行了下 是没有问题的!!如果把我导出到文本文件的内容从文本文件复制出来后,在执行$handle=fopen("1.txt","r"); 
    $data=fgetcsv($handle,1024,"|"); 
    $num=count($data); 
    print_r($data); 
    又是正常的! 我也搞不懂了,觉得跟编码有关的 有些东西会弄糊涂!!