Hướng dẫn dùng world wrap trong PHP
Hàm Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức. Cú phápCú pháp: Trong đó:
Cách sử dụng hàm wordwrap: Bài viết này được đăng tại [free tuts .net] Code $text = "this is a test stringgggggggggggggggggggggggg"; echo $newtext = wordwrap($text, 20, "-")." Kết quả this is a test-stringgggggggggggggggggggggggg this is-a test-stringgg-gggggggg-gggggggg-gggggg this is-a test-stringgggggggggggggggggggggggg Tham khảo: php.net
Định nghĩa và sử dụngThuộc tính word-wrap sẽ làm cho những từ dài xuống hàng mà không làm vỡ layout. Cấu trúctag { word-wrap: giá trị; } word-wrap có các giá trị như sau:
Ví dụHTML viết:
CSS viết:p { border: 1px solid #cc0000; width: 150px; } Hiển thị trình duyệt khi chưa có word-wrap:HỌC WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEB CHUẨN Thêm thuộc tính word-wrap vào CSS:p { border: 1px solid #cc0000; width: 150px; word-wrap: break-word; } Hiển thị trình duyệt khi có word-wrap:HỌC WEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEB CHUẨN Hàm Bài viết này được đăng tại freetuts.net, không được copy dưới mọi hình thức. Cú phápCú pháp: Trong đó:
Cách sử dụng hàm wordwrap: Bài viết này được đăng tại [free tuts .net] Code $text = "this is a test stringgggggggggggggggggggggggg"; echo $newtext = wordwrap($text, 20, "-")." Kết quả this is a test-stringgggggggggggggggggggggggg this is-a test-stringgg-gggggggg-gggggggg-gggggg this is-a test-stringgggggggggggggggggggggggg Tham khảo: php.net (PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8) wordwrap — 打断字符串为指定数量的字串 说明wordwrap( 参数str 输入字符串。 width 列宽度。 break 使用可选的 cut 如果 范例示例 #1 wordwrap() 范例
$newtext; 以上例程会输出: The quick brown fox 示例 #2 wordwrap() 范例
"$newtext\n"; 以上例程会输出: A very long wooooooo ooooord. 示例 #3 wordwrap() 例子
"$newtext\n";
以上例程会输出: A very long woooooooooooooooooord. and something 参见
Alhadis ¶ 7 years ago
$word_length = strlen($words[$i]); ju1ius ¶ 10 years ago
Dave Lozier - dave at fusionbb.com ¶ 16 years ago
frans-jan at van-steenbeek dot R-E-M-O-V-E dot net ¶ 16 years ago
michdingpayc ¶ 2 months ago
altin_bardhi at yahoo dot co dot uk ¶ 11 years ago
strlen($value) >= $chunk_length){//Split the chunks/words which are longer than $chunk_length
Peter ¶ 15 years ago
answers at clearcrescendo.com ¶ 3 years ago
$del=' at '; 'sanneschaap' dot $del dot 'gmail dot com' ¶ 14 years ago
php at maranelda dot org ¶ 13 years ago
= "some text that must wrap nice";$a = wordwrap($a, 9); info at hsdn dot org ¶ 11 years ago
mb_substr($string, $i, 1, 'UTF-8') == ' ') Marcin Dobruk [zuku3000 at yahoo dot co dot uk] ¶ 13 years ago
ojs-hp at web dot de ¶ 12 years ago
$newText[] = $word; //add word to array maikuolan at gmail dot com ¶ 9 years ago
kozimbek at mail dot ru ¶ 7 years ago
phil_marmotte at yahoo dot fr ¶ 8 years ago
joachim ¶ 14 years ago
tuxedobob ¶ 5 years ago
zac dot hester at gmail dot com ¶ 7 years ago
bruceboughton @ google mail ¶ 17 years ago
nbenitezl[arroba]gmail[dot]com ¶ 11 years ago
$newStr; Matt at newbiewebdevelopment dot idk ¶ 13 years ago
simbiat at bk dot ru ¶ 5 years ago
|