±ÛÀÚ ±úÁü ¾øÀÌ ¹®ÀÚ¿ ÀÚ¸£±â(hex2bin ÇÔ¼ö ÀÌ¿ë) |
|
|
 |
13³â Àü |
<?
echo "<form action=$PHP_SELF>
ÀÚ¸¦ ¹®ÀÚ¿ : <input type=text size=35 name=start value="$start"><br>
ÀÚ¸¦ ±æÀÌ : <input type=text size=5 name=end value=$end><input type=submit value="^___^"></form>";
echo "ÀÚ¸¦¹®ÀÚ¿ : $start<br>
ÀÚ¸¦ ±æÀÌ : $end<br><br>
<b>ÀÚ¸£°í ³ ¹®ÀÚ¿ : ".cut_str($start,$end)."</b>";
function cut_str($str,$length) {
$temp = "";
$ret_str = "";
if(strlen($str) > $length) $dot = "....";
for($i=0;$i<$length;$i++) {
$b = bin2hex(substr($str,$i,1));
if(hexdec($b) < 127 && $temp == "") $ret_str .= chr(hexdec($b));
else {
if($temp == "") $temp = $b;
else {
$temp .= $b;
$ret_str .= hex2bin($temp);
$temp = "";
}
}
}
return $ret_str.$dot;
}
function hex2bin($str) { //-- bin2hex ÀÇ ¿ªÇÔ¼ö
$ret_str = "";
for($i=0;$i<strlen($str);$i+=2) {
$ge_str = substr($str,$i,2);
$ret_str .= chr(hexdec($ge_str));
}
return $ret_str;
}
?>
|
|
̵̧ : 559 |
̵̧
¸ñ·Ï
|
|