ฟังก์ชั่น printf()
ความหมายของฟังก์ชั่นและการใช้งาน
ใช้แสดงผลข้อความบน page โดยมีการจัดรูปแบบไว้ ด้วยฟังก์ชั่น printf()
รูปแบบการเขียน (Syntax)
int printf ( string $format [, mixed $args [, mixed $... ]] )
ตัวอย่าง
<?php
function printf_array($format, $arr)
{
return call_user_func_array('printf', array_merge((array)$format, $arr));
}
?>
<?php
printf("%.02lf\n", 1.035);
printf("%.02lf\n", round(1.035, 2));
?>