ฟังก์ชัน ucwords() ใช้สำหรับแปลงตัวอักษรแรกของแต่ละคำในสตริงเป็นตัวพิมพ์ใหญ่ (uppercase)
รูปแบบการใช้งาน (Syntax)
ucwords(str)
พารามิเตอร์ (Parameters)
str − สตริงที่ต้องการแปลง
ค่าที่ส่งกลับ (Return Value)
ฟังก์ชัน ucwords() ส่งคืนสตริงที่แปลงแล้ว
ตัวอย่างการใช้งาน
<?php
echo ucwords("This is it!");
?>
ผลลัพธ์ (Output)
This Is It!
ตัวอย่างการใช้งาน
ตัวอย่างกับตัวคั่นกำหนดเอง:
<?php $s = "#demo#text"; $sep = '#'; $res = ucwords($s, $sep); print_r($res); ?>
ผลลัพธ์ (Output)
#demo#text