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
PHP Web Logs (BLogs)
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
Submit Site
Forex Trading Online forex trading platform

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 : Text Wrapping
Categories : PHP, HTML and PHP, Strings Update Picture
Jens Kohl
Date : Feb 15th 2001
Grade : 5 of 5 (graded 1 times)
Viewed : 3868
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Jens Kohl
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
function wraptext($text,$warp) {
    $text = explode(" ", $text);
    $i = 0; $length = 0;
        while ($i <= count($text)) {
            $length += strlen($text[$i]);
                 if ($length <= $warp) {
                    $output .= $text[$i]." ";
                    $i++;
                } else {
                    $output .= "\n";
                    $length = 0;
                }
        }
    return $output;
}

// Usage :
// =======
// $text = "very long text";
// $forhtml = nl2br(wraptext($text,72));
// echo $forhtml;
// $formail = mail($email,$subject,wraptext($text,72));

?>



function textwrap will wrap text to any desired width using <BR>\n as the default line break. Default wrap width is 80 columns.
Categories : Strings, HTML and PHP, PHP
Customizable encoding and decoding strings with security.
Categories : PHP, Strings, HTML and PHP
Pull deliniated text strings into a "SELECT" statement in a form.
Categories : HTML and PHP, PHP, Strings
Produces browser-safe strings while preserving HTML tags.
Categories : Strings, HTTP, PHP, HTML and PHP
string justification align center text
Categories : Strings, PHP, HTML and PHP
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
A simple class with some HTML output functions that would come in handy for consistent page layout etc.
Categories : PHP, PHP Classes, HTML and PHP, HTML, Navigation
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
Calendar using Date function
Categories : HTML and PHP, PHP, Date Time, Calendar
Constantly refresh your PHP/HTML page data.
Categories : PHP, HTML and PHP, Sybase
Avoiding or Detecting high bit characters in a string. Useful when you want to create a valid RSS feed
Categories : PHP, Strings, Unicode, Regexps, Rich Site Summary (RSS)
Select with current month
Categories : PHP, HTML and PHP, Date Time, Arrays
PHP4 session helper HTML file.
Categories : PHP, Java Script, HTML and PHP, Sessions
A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL