메뉴 건너뛰기

app

[PHP] letter, word, line 수 세기

박영식2009.08.21 23:35조회 수 4545댓글 0

    • 글자 크기
$file1=file(파일명);
$file1size=sizeof($file1);
        for($i=0;$i<sizeof($file1); $i++)
        {
         $b=0;
         while($file1[$i][$b++]){
          $file1letter++;
          if($file1[$i][$b]=="n" || $file1[$i][$b]==" ")
           $file1word++;
          echo $file1word[$i][$b];
         }
        }

file1letter, file1word, file1size 각 변수에 해당 값을 활용할 수 있다.

php의 file함수로 한 줄 씩 배열화 시키고, sizeof로 line수를 얻을 수 있으며, while문으로 각 character의 공백과 new line을 통해 카운팅하는 원리이다.
박영식 (비회원)
    • 글자 크기
[xcode] Let me introduce (by 박영식) [c] line 수 세는 프로그램 (by 박영식)

댓글 달기

박영식
2010.09.09 조회 4984
박영식
2010.05.25 조회 4401
박영식
2010.01.14 조회 5182
박영식
2009.09.21 조회 4375
박영식
2008.08.18 조회 6302
박영식
2008.08.17 조회 4480
박영식
2008.07.24 조회 4968
박영식
2008.07.23 조회 8250
박영식
2008.07.22 조회 3573
박영식
2008.04.11 조회 2422
박영식
2008.01.20 조회 2268
박영식
2007.12.23 조회 3440
첨부 (0)
위로