ฟังก์ชัน wordwrap()
ชึ้นบรรทัดใหม่ให้ตามความยาวที่กำหนด ด้วยฟังก์ชัน wordwrap()

 

รูปแบบ
wordwrap(string,width,break,cut)

string คือ สตริง

width คือ ความยาวที่ต้องการ default คือ 75

break คือ ตัวอักษรที่จะเติมเมื่อสตริงครบตามที่กำหนด 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);

?>

 

ผลลัพธ์
I am a boy in
the wonderfull
world.
Hellooooooooooo
ooooooooo

 


กลับ menu php