랜덤으로 한글3글자 어떻게 만드는지 아시는분^^ php 였으면 좋겠습니다~
댓글 2개
<?
$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
게시글 목록
| 번호 | 제목 |
|---|---|
| 284348 | |
| 284336 | |
| 284333 | |
| 284332 | |
| 284320 | |
| 284318 | |
| 284316 | |
| 284313 | |
| 284307 | |
| 284306 | |
| 284303 | |
| 284298 | |
| 284296 | |
| 284290 | |
| 284286 | |
| 284280 | |
| 284277 | |
| 284272 | |
| 284261 | |
| 284259 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기