PHP max()ฟังก์ชั่น
ตัวอย่าง
ค้นหาค่าสูงสุดด้วยฟังก์ชัน max()
<?php
echo(max(2,4,6,8,10) . "<br>");
echo(max(22,14,68,18,15) . "<br>");
echo(max(array(4,6,8,10)) . "<br>");
echo(max(array(44,16,81,12)));
?>
ความหมายและการใช้งาน
ฟังก์ชัน max() ส่งคืนค่าสูงสุดในอาร์เรย์ หรือค่าสูงสุดของค่าที่ระบุหลายค่า
ไวยากรณ์
max(array_values);
or
max(value1,value2,...);
ค่าพารามิเตอร์
Parameter | Description |
---|---|
array_values | Required. Specifies an array containing the values |
value1,value2,... | Required. Specifies the values to compare (must be at least two values) |
รายละเอียดทางเทคนิค
คืนมูลค่า: | ค่าสูงสุดที่เป็นตัวเลข |
---|---|
ประเภทการคืนสินค้า: | ผสม |
รุ่น PHP: | 4+ |
❮ การอ้างอิงทางคณิตศาสตร์ PHP