PHP:Convert Function รวมฟังก์ชันแปลงเลขฐาน

PHP Knowledge เป็น บอร์ดรวามความรู้ php เน้นบทความ แนวทางการเขียนโปรแกรม บันทึกกันลืม เพื่อให้สมาชิกได้เขียนความรู้ที่ตัวเองมีให้สมาชิกท่านอื่นๆ ได้ เข้ามาอ่าน และ ไว้อ่านเองกันลืมด้วย

Moderator: mindphp, ผู้ดูแลกระดาน

anuwat somsakul
PHP Full Member
PHP Full Member
โพสต์: 44
ลงทะเบียนเมื่อ: 08/08/2018 9:49 am

PHP:Convert Function รวมฟังก์ชันแปลงเลขฐาน

โพสต์ที่ยังไม่ได้อ่าน โดย anuwat somsakul »

รวมฟังก์ชันแปลงเลขฐาน

function : bindec ( string );
return type : int
content : ใช้แปลงเลขฐาน 2 เป็นเลขฐาน 10
example : echo bindec ( "11111111" );
comment : bin ย่อมาจาก binary , dec ย่อมาจาก decimal


function : decbin ( number );
return type : string
content : ใช้แปลงเลขฐาน 10 เป็นเลขฐาน 2
example : echo decbin ( 128 );
comment : dec ย่อมาจาก decimal , bin ย่อมาจาก binary

function : octdec ( string );
return type : int
content : ใช้แปลงเลขฐาน 8 เป็นเลขฐาน 10
example : echo octdec ( "100" );
comment : oct ย่อมาจาก octal , dec ย่อมาจาก decimal

function : decoct ( number );
return type : string
content : ใช้แปลงเลขฐาน 10 เป็นเลขฐาน 8
example : echo decoct ( 16 );
comment : dec ย่อมาจาก decimal ,oct ย่อมาจาก octal

function : hexdec ( string );
return type : int
content : ใช้แปลงเลขฐาน 16 เป็นเลขฐาน 10
example : echo hexdec ( "abc" );
comment : hex ย่อมาจาก hexadecimal ,dec ย่อมาจาก decimal

function : dechex ( number );
return type : string
content : ใช้แปลงเลขฐาน 10 เป็นเลขฐาน 16
example : echo dechex ( 200 );
comment : dec ย่อมาจาก decimal ,hex ย่อมาจาก hexadecimal

function : base_convert ( string, frombase, tobase );
return type : string
content : ใช้แปลงเลขฐาน จากฐานที่กำหนด เป็นเลขฐานที่กำหนด
example : echo base_convert ( "11111111", 2, 10 );
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: Google Adsense [Bot] และบุคลทั่วไป 76