랜덤으로 한글3글자 어떻게 만드는지 아시는분^^ php 였으면 좋겠습니다~ 정보
랜덤으로 한글3글자 어떻게 만드는지 아시는분^^ php 였으면 좋겠습니다~본문
랜덤으로 한글3글자 어떻게 만드는지 아시는분^^ php 였으면 좋겠습니다~
댓글 전체
<?
$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
$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
와우 대단하세요^^ 너무 감사드립니다^^