WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Wraps text to any desired width with customizable line break. Defaults are 80 columns and '<BR>\n' Should be trivial to work in 2.0.1 Remove optional arguments to start.
Categories : Complete Programs, PHP Update Picture
Richard Lynch
Date : Jan 17th 1999
Grade : Be the 1st to grade this Code Example
Viewed : 3745
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Richard Lynch
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?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