게시판의 조회수등에서 천단위 숫자를 변환하려는데요.. 정보
게시판의 조회수등에서 천단위 숫자를 변환하려는데요..본문
예를들어 조회수가 1537 이면 1.5k 로
변환시키는 방법을 알고 싶습니다.
변환시키는 방법을 알고 싶습니다.
댓글 전체
http://kr2.php.net/manual/en/function.number-format.php
코멘트에 있네요.
simpler function to convert a number in bytes, kilobytes....
<?php
function bytes($a) {
$unim = array("B","KB","MB","GB","TB","PB");
$c = 0;
while ($a>=1024) {
$c++;
$a = $a/1024;
}
return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c];
}
?>
코멘트에 있네요.
simpler function to convert a number in bytes, kilobytes....
<?php
function bytes($a) {
$unim = array("B","KB","MB","GB","TB","PB");
$c = 0;
while ($a>=1024) {
$c++;
$a = $a/1024;
}
return number_format($a,($c ? 2 : 0),",",".")." ".$unim[$c];
}
?>
감사합니다. 이렇게 하니 잘 되네요.
<?
if($list[$i][wr_hit]>1000000) $list[$i][wr_hit]=round(($list[$i][wr_hit]/1000000),1).m;
else if($list[$i][wr_hit]>1000) $list[$i][wr_hit]=round(($list[$i][wr_hit]/1000),1).k;
?>
<?=$list[$i][wr_hit]?>
<?
if($list[$i][wr_hit]>1000000) $list[$i][wr_hit]=round(($list[$i][wr_hit]/1000000),1).m;
else if($list[$i][wr_hit]>1000) $list[$i][wr_hit]=round(($list[$i][wr_hit]/1000),1).k;
?>
<?=$list[$i][wr_hit]?>