PHP ¼ýÀÚ ÃµÀÚ¸®¸¶´Ù ÄÞ¸¶(½°Ç¥) Âï±â |
|
|
 |
13³â Àü |
PHP¿¡¼ ¼ýÀÚ ÃµÀÚ¸® ¸¶´Ù ÄÞ¸¶¸¦ Âï¾î ÁÙ·Á¸é, number_format ÇÔ¼ö¸¦ ÀÌ¿ëÇÕ´Ï´Ù.
»ç¿ë¹ýµµ ¾ÆÁÖ ½¬¿ö¼ number_format ÇÔ¼öÀÇ Ã¹¹ø° ÀÎÀÚ¿¡ ¼ýÀÚ¸¸ ´ëÀÔÇØ ÁÖ¸éµË´Ï´Ù.
¿¹) number_format(¼ýÀÚ)
number_format ÇÔ¼ö´Â ÇϳªÀÇ ÀÎÀÚ¸¦ ´õ ¹ÞÀ»¼ö Àִµ¥ µÎ¹ø° ÀÎÀÚ´Â Ãâ·ÂÇÒ ¼Ò¼ýÁ¡ÀÇ ÀÚ¸®¸¦ °áÁ¤ÇÕ´Ï´Ù.
¿¹) number_format( ¼ýÀÚ, ¼Ò¼öÁ¡ÀÚ¸®¼ö )
¾Æ·¡´Â ÄÞ¸¶¸¦ ºÙÀÌ°í, ÄÞ¸¶¸¦ Á¦°ÅÇÏ´Â °£´ÜÇÑ ¿¹Á¦ÀÔ´Ï´Ù. °á±¹Àº ÆÁµµ ¾Æ´Ï¶ó´Â °Å ¤Ð.¤Ð
<?
$num = 10000000;
$num = number_format($num);
echo $num; // ÄÞ¸¶ºÙÀÓ
echo "<br>\n";
$num=str_replace(",","",$num);
echo $num; // ÄÞ¸¶Á¦°Å
echo "<br>\n";
$num = 10000000.22222;
$num = number_format($num, 3);
echo $num // ¼Ò¼öÁ¡ ¼¼Â°ÀÚ¸®±îÁö Ãâ·Â
?>
|
|
̵̧ : 657 |
̵̧
¸ñ·Ï
|
|