웹마스터 팁

원고지 함수;;

2002.02.07 15:47

디쓰

이지보드의 원고지스킨을 보구 php로 만들어보았습니다
자바스크립으로하는게 더 좋을듯;;;
http://jamaica.iyedong.net/this/wongoji.php

<?php

function wongoji($str,$width)
{
    //  한자씩 잘라서 배열로....
    $lenth = strlen($str);

    for ($pos = 0 ; $pos < $lenth ; $pos = $pos + $s_pos ) {

        $s_pos = 1;
        $sub = substr($str,$pos,1);

        if(ord($sub) >= 127) $s_pos++;

        $sub = substr($str,$pos,$s_pos);

        $sub_char[] = $sub;
     }    // 만들고;;

     $height = ceil(count($sub_char) / $width); // 원고지의 세로 칸수

     echo "<table cellspacing='0' border='1' bordercolor=#F38885>";
     for ($h = 0 ; $h < $height ; $h++) {

         $start_h = $width * $h; //세로 첫칸에 시작할 s_word의 키값-_-;;

         echo "<tr>";

         for($w = 0 ; $w <= $width ; $w++) {

            echo "<td width='20' height='20' align='center'><img src=blank.gif width='0'>$sub_char[$start_h]</td>";
            $start_h++;

         }

         echo "</tr>";

     }
     echo "</table>";
}


$str = "Mysql 4.0.1 개발 버젼이 발표되었습니다.자세한 내용은 http://www.mysql.com/ 에서 확인하시길 바랍니다.";
wongoji($str,25);

?>