Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> PHP

ฟังก์ชัน localeconv() ใน PHP

คำอธิบาย

ฟังก์ชัน localeconv() ใช้ดึงข้อมูลการจัดรูปแบบตัวเลขและสกุลเงินตาม locale ปัจจุบันที่ตั้งค่าด้วย setlocale() คืนค่าเป็นอาร์เรย์เชื่อมโยงที่มีข้อมูลครบถ้วน

รูปแบบการใช้งาน (Syntax)

localeconv(): array

พารามิเตอร์

ไม่มีพารามิเตอร์

ค่าที่คืนกลับ (Return Value)

คืนค่าอาร์เรย์ที่มีข้อมูลต่อไปนี้:

  • decimal_point - ตัวคั่นทศนิยม
  • thousands_sep - ตัวคั่นพัน
  • int_curr_symbol - สัญลักษณ์สกุลเงินระหว่างประเทศ (USD)
  • currency_symbol - สัญลักษณ์สกุลเงินท้องถิ่น ($)
  • mon_decimal_point - ตัวคั่นทศนิยมของเงิน
  • mon_thousands_sep - ตัวคั่นพันของเงิน
  • positive_sign - เครื่องหมายบวก
  • negative_sign - เครื่องหมายลบ
  • int_frac_digits - ทศนิยมระหว่างประเทศ
  • frac_digits - ทศนิยมท้องถิ่น
  • p_cs_precedes - สกุลเงินหน้าค่าบวก (1=หน้า, 0=หลัง)
  • p_sep_by_space - เว้นวรรคระหว่างสกุลเงินและค่าบวก
  • n_cs_precedes - สกุลเงินหน้าค่าลบ
  • n_sep_by_space - เว้นวรรคระหว่างสกุลเงินและค่าลบ
  • p_sign_posn - ตำแหน่งเครื่องหมายบวก (0-4)
  • n_sign_posn - ตำแหน่งเครื่องหมายลบ (0-4)
  • grouping - การจัดกลุ่มตัวเลข
  • mon_grouping - การจัดกลุ่มตัวเลขเงิน

ตัวอย่างการใช้งาน

<?php
setlocale(LC_ALL, "US");
$info = localeconv();
print_r($info);
?>

ผลลัพธ์

Array
(
    [decimal_point] => .
    [thousands_sep] => ,
    [int_curr_symbol] => USD
    [currency_symbol] => $
    [mon_decimal_point] => .
    [mon_thousands_sep] => ,
    [positive_sign] => 
    [negative_sign] => -
    [int_frac_digits] => 2
    [frac_digits] => 2
    [p_cs_precedes] => 1
    [p_sep_by_space] => 0
    [n_cs_precedes] => 1
    [n_sep_by_space] => 0
    [p_sign_posn] => 1
    [n_sign_posn] => 1
    [grouping] => Array ( [0] => 3 )
    [mon_grouping] => Array ( [0] => 3 )
)

หมายเหตุ: ผลลัพธ์ขึ้นอยู่กับ locale ที่ตั้งค่าและระบบปฏิบัติการ