作者SuLaPKLa (= =)
看板PHP
标题[请益] 请问读取txt档 空格 的问题
时间Sun Sep 25 21:26:08 2011
想要使用php读取txt档
txt档内全部是用空格来区分
但却有的空格多 有的空格少
用explode函数 无法辨认为正确栏位
请问各位大大 有什麽更好的涵数吗???
<?php
$file = fopen($_GET["name"], "r") or exit("Unable to open file!");
while(!feof($file))
{
$show = explode(" " ,fgets($file));
echo $show[0]." ".$show[1]. "<br />";
}
fclose($file);
?>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.32.245.244
1F:→ bibo9901:有固定格式的话, 考虑 regexp 09/25 21:44
2F:→ qwertmn:你是说CSV档用空白做分隔符号的?试试看split 09/25 22:23
3F:推 mervynW:preg_split 09/26 07:09
4F:→ SuLaPKLa:没有固定格式 其他单位的工程师写的太烂了 我试试看 谢谢 10/01 19:02