2014-09-13 3 views
0

그래서 로그를 표시하기 위해 fopen 및 fread 문을 얻으려고하고 각 항목의 줄이 바뀌며 어떻게 코드를 가져 와서 .txt와 같은 형식으로 만들 수 있습니까? ,PHP fopen 및 fread 적절한 형식

가 .txt :

[2014/1/19 - 22:49:37] Josh (IP:174.101.171.132) has edited auction 0 expire time to 60 
[2014/1/19 - 22:49:43] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled) 
[2014/1/19 - 22:49:51] Josh (IP:174.101.171.132) has edited auction 0 item description to Free House 
[2014/1/19 - 22:49:59] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 5000000 
[2014/1/19 - 22:50:31] Josh (IP:174.101.171.132) has edited auction 0 enabled to 0 (disabled) 
[2014/1/19 - 22:50:37] Josh (IP:174.101.171.132) has edited auction 0 item description to none 
[2014/1/19 - 22:50:45] Josh (IP:174.101.171.132) has edited auction 0 item description to (none) 
[2014/1/19 - 22:50:50] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 0 
[2014/1/20 - 11:40:09] Josh (IP:174.101.171.132) has edited auction 0 item description to Testing House 
[2014/1/20 - 11:40:14] Josh (IP:174.101.171.132) has edited auction 0 expire time to 1 
[2014/1/20 - 11:40:18] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 1 
[2014/1/20 - 11:40:21] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled) 

PHP 돌아 가기 :

[2014/1/19 - 22:49:37] Josh (IP:174.101.171.132) has edited auction 0 expire time to 60 [2014/1/19 - 22:49:43] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled) [2014/1/19 - 22:49:51] Josh (IP:174.101.171.132) has edited auction 0 item description to Free House [2014/1/19 - 22:49:59] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 5000000 [2014/1/19 - 22:50:31] Josh (IP:174.101.171.132) has edited auction 0 enabled to 0 (disabled) [2014/1/19 - 22:50:37] Josh (IP:174.101.171.132) has edited auction 0 item description to none [2014/1/19 - 22:50:45] Josh (IP:174.101.171.132) has edited auction 0 item description to (none) [2014/1/19 - 22:50:50] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 0 [2014/1/20 - 11:40:09] Josh (IP:174.101.171.132) has edited auction 0 item description to Testing House [2014/1/20 - 11:40:14] Josh (IP:174.101.171.132) has edited auction 0 expire time to 1 [2014/1/20 - 11:40:18] Josh (IP:174.101.171.132) has edited auction 0 starting bid to 1 [2014/1/20 - 11:40:21] Josh (IP:174.101.171.132) has edited auction 0 enabled to 1 (Enabled) 
+0

미안 해요, 난 당신이 내가 하부의 혼란을 정리 최초의 편집에 두 번 게시 편집했습니다. ;) – lxg

답변

0

다음

$lines = file('/path/to/file'); 

당신에게 모든 요소는 파일의 라인 배열을 제공합니다. 나는이 실제 문제가 실현 될 때까지

http://php.net/file

+0

작동! 당신의 도움을 주셔서 감사합니다!! – SerenityJosh

0

사용

는 fgets 다시는 fgets 파일에서 한 줄의 텍스트를 광고합니다. HTML 스트림으로 출력하는 경우 한 번에 한 줄 씩 출력하고 각 줄 끝에서 <BR>을 추가하십시오. 또는 <pre></pre> 태그를 사용하고 전체 파일을 그대로 출력하십시오.