다음 code snippet으로 웹에서 긁어온 내용을 UTF-8로 저장할 수 있다.
<?php
function file_get_contents_utf8($fn) {
$content = file_get_contents($fn);
return mb_convert_encoding($content, 'UTF-8',
mb_detect_encoding($content, 'UTF-8, ISO-8859-1', true));
}
?>
'언어 > PHP, DB' 카테고리의 다른 글
mysql에서 한글 설정 (0) | 2012.11.27 |
---|---|
strpos_array() : 여러 번의 strpos 결과를 행렬로 저장할 때 (0) | 2012.11.16 |
file_get_contents() : Web content를 변수로 가져오기 (0) | 2012.11.16 |
[mysql] 비밀번호 관련 (0) | 2011.08.17 |
[mysql + php] login페이지 만들기 (0) | 2011.07.18 |