|
|
|
<?php
function textwrap($text, $wrap=80, $break= '<BR>\n'){
$len = strlen($text);
if ($len > $wrap){
$h = '';
$lastWhite = 0;
$lastChar = 0;
$lastBreak = 0;
while ($lastChar < $len){
$char = substr($text, $lastChar, 1);
if (($lastChar - $lastBreak > $wrap) && ($lastWhite > $lastBreak)){
$h .= substr($text, $lastBreak, ($lastWhite - $lastBreak)) . $break;
$lastChar = $lastWhite + 1;
$lastBreak = $lastChar;
}
/* You may wish to include other characters as valid whitespace... */
if ($char == ' ' || $char == chr(13) || $char == chr(10)){
$lastWhite = $lastChar;
}
$lastChar = $lastChar + 1;
}
$h .= substr($text, $lastBreak);
}
else{
$h = $text;
}
return $h;
}
?>
<HTML>
<HEAD><TITLE>Textwrap Example</TITLE></HEAD>
<BODY>
<?php
$test = "This is a test. This is only a test. Had this
been a real emergency you would have been instructed to put your head between your
knees and pray.";
echo( "$test<BR>\n<BR>\n");
for ($w = 80; $w > 0; $w = $w - 10){
$wrapped = textwrap($test, $w);
echo( "$w<BR>\n$wrapped<BR>\n<BR>\n");
}
?>
</BODY>
</HTML>
|
|
| This script allows people to add their favorite quotes to your website. This
could easily be modified to be a guestbook script or comment page script. Categories : PHP, Complete Programs, HTML and PHP, Misc | | | phpYellow Pages Standard Categories : PHP, Complete Programs, Databases, Directories, Search | | | A database abstraction layer for the PHP 3.0 ODBC module. It supports persistent connections, fetching rows into arrays, prepare/execute (variable binding) and has a new and improved error interface. Categories : Databases, PHP, Complete Programs | | | Client classes for Dictionary servers UPDATED: 2000-06-06 Categories : Network, Search, Complete Programs, PHP Classes, PHP | | | phpEasyMail: An easy way to send data from HTML-forms via EMail. Categories : Email, HTML and PHP, Complete Programs, PHP | | | BBS system for easy customization. Utilizes mySQL. Categories : Complete Programs, MySQL, PHP, Databases | | | Validator 98 - a PHP-script to generate form-validation-code in JavaScript. Categories : Complete Programs, Java Script, PHP, HTML and PHP | | | php Free chat simple fast and customizable chat server that uses a simple filesystem for message and nickname storage Categories : PHP, AJAX, XML, Complete Programs | | | simple shopping cart for php3 Categories : PHP, PHP Classes, Complete Programs, Ecommerce | | | Modification of Shane Caraveo's guestbook. Uses ODBC...some code modifications Categories : ODBC, Databases, Complete Programs, PHP | | | PHP-MySQL shopping cart
Categories : PHP, Ecommerce, Complete Programs | | | Create and restore backup of MySQL databases Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs | | | GroupIT Content Management and Community Engine Categories : PHP, Complete Programs, Content Management | | | Rich Editor (RE) is a cross-browser WYSIWYG html editor Categories : Content Management, Editors and IDEs, PHP, Complete Programs | | | DBE - Database Expander: Edit PostgreSQL individual database tables online via your Web browser! Categories : PostgreSQL, Complete Programs, Databases, PHP Classes, PHP | |
|
|