글자르기 하실때 한글 자르기 땜시 고생마니 되잖아여
근데 시중에 돌아다니는 한글자르기는 2벌식만 적용되더라구영...
그래서 그냥 밑에서 어느분이 올리신거 약간 수정봐서 올려봅니다
초보니...욕은 마시고 수정해야 할 부분을 말해주세요!!!
function cut_str($msg,$cut_size,$str_type="2",$tail="...") {
if($cut_size <= 0) return $msg;
$msg = strip_tags($msg);
$msg = str_replace("∓quot;","\"",$msg);
if(strlen($msg) <= $cut_size) return $msg;
for($i=0;$i<$cut_size;$i++){
if(ord($msg[$i])>127){
$han++;
}else{
$eng++;
}
}
$han=ceil($han/$str_type)*3;
$cut_size = $han + $eng;
$tmp = substr($msg,0,$cut_size);
$tmp .= $tail;
return $tmp;
}
사용시에는
$title=cut_str(제목변수,자를 길이,브라우져 타입,뒤에 붙일내용);
브라우져타입은.....두벌식인지 세벌식인지를 숫자로 나타내면 됩니다....
출처 : http://www.phpschool.com
php
bibaram2005.02.18 · 3분 읽기 · 조회 4,283
글자르기 urf-8등에서도 먹히게 하기.....
bibaram2005.02.18 · 3분 읽기 · 조회 4,283이어서 읽기
html↗
favicon.ico Status 404 해결방법
favicon.ico 파일이 있어서 경로를 직접 설정해주는 게 최선이지만favicon.ico가 없다면 아래와 같이 넣어준다. <html> <head> <link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"> </head…
2020.09.25·1분 읽기
php↗
Codeigniter api에서 어떤 곳에서 보낸 json
$aData = var_export(file_get_contents('php://input'),TRUE); $aArr = json_decode(str_replace("'", "", $aData), true); 버전에 따라 다를 수도 있음 $this->input->raw_input_stream 이렇게 해보면 됨
2020.09.11·1분 읽기
server↗
apache 이미지 로그 안쌓이게 하기
웹서버를 운영하다 보면 Apache log 가 엄청나게 많이 쌓인다. logrotate 가 실행되고 있다면 어느 정도 로그가 정리가 되겠지만 아니라면 로그가 쌓여서 서버가 엄청 느려지거나 서버가 다운될 수도 있다. ErrorLo…
2020.02.17·2분 읽기
댓글 0
아직 댓글이 없습니다.