메뉴 건너뛰기

app

[PHP] letter, word, line 수 세기

박영식2009.08.21 23:35조회 수 4206댓글 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 조회 4793
박영식
2010.05.25 조회 4102
박영식
2010.01.14 조회 4971
박영식
2009.09.21 조회 4147
박영식
2008.08.18 조회 6064
박영식
2008.08.17 조회 4194
박영식
2008.07.24 조회 4623
박영식
2008.07.23 조회 8003
박영식
2008.07.22 조회 3352
박영식
2008.04.11 조회 2199
박영식
2008.01.20 조회 2041
박영식
2007.12.23 조회 3224
첨부 (0)
위로