테스트 사이트 - 개발 중인 베타 버전입니다

랜덤으로 한글3글자 어떻게 만드는지 아시는분^^ php 였으면 좋겠습니다~

· 12년 전 · 2361 · 2
랜덤으로 한글3글자 어떻게 만드는지 아시는분^^ php 였으면 좋겠습니다~

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 2개

12년 전
<?
$chr_str = "\\u".dechex(rand( 44032 , 55203 ))."\\u".dechex(rand( 44032 , 55203 ))."\\u".dechex(rand( 44032 , 55203 ));
$s = preg_replace("/[\s]/s", "\u0020", $chr_str);
$s = preg_replace("/((\\\u([0-9A-F]+))|(.*?))/ie", "conv(\"$1\")", $s);
$s = rawurldecode($s);
echo iconv('utf-16be', 'CP949', $s);

// 정규식으로 뜯어낸 문자열을 적절히 변환
function conv($hex)
{
// 빈 값이면 빈값 반환
if (strlen($hex)<1) return '';
// 유니코드 문자열이 아니라면 url decode 되도록 구성하여 반환
if (isUnicode($hex)==false) return '%00'.$hex;

$hex = getFormatted($hex);

$sResult = '';
for ($i=0; $i<strlen($hex); $i++) {
if ($i%2==0) $sResult .= '%';
$sResult .= $hex[$i];
}

return $sResult;
}

// 유니코드 문자열인지 체크
function isUnicode($hex)
{
return strpos($hex, '\u')===0;
}

// urldecode 할 수 있도록 포매팅
function getFormatted($hex)
{
$hex = str_replace('\u', '', $hex);

$max = 4;
$len = strlen($hex);
if ($len<$max) {
for ($i=$len; $i<$max; $i++) $hex = '0'.$hex;
}

return $hex;
}
?>

참고 - http://bloodguy.tistory.com/666
12년 전
와우 대단하세요^^ 너무 감사드립니다^^

게시글 목록

번호 제목
284172
284170
284167
284164
284161
284159
284155
284152
284151
284148
284142
284141
284137
284136
284135
284127
284121
284120
284116
284115