ฟังก์ชัน wordwrap()
ความหมายของฟังก์ชันและการใช้งาน
การขึ้นบรรทัดใหม่ตามความยาวที่กำหนดด้วยฟังก์ชัน wordwrap()
รูปแบบการเขียน (Syntax)
wordwrap(string, width, break, cut)
- string คือ ข้อความ
- width คือ ความยาว (Default คือ 75)
- break คือ ตัวอักษรที่จะเติมเมื่อ String ครบตามที่กำหนด (Default คือ "\n")
- cut คือ กำหนดว่าจะ wrap หรือไม่ (Default คือ FALSE หรือ no-wrap)
การ Return ค่า
String
ตัวอย่าง
<?php
$str = "I am a boy in the wonderfull world. Helloooooooooooooooooooo";
echo wordwrap($str,15,"<br />",TRUE);
?>
ผลลัพธ์/h3>
I am a boy in
the wonderfull
world.
Hellooooooooooo
ooooooooo