WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search


Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 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



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 : 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 Update Picture
Richard Lynch
Date : Jul 10th 1998
Grade : 1 of 5 (graded 1 times)
Viewed : 20062
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  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>



Customizable encoding and decoding strings with security.
Categories : PHP, Strings, HTML and PHP
Parse string to find sub-string between two arbitrary strings
Categories : PHP, Strings, HTML and PHP, Arrays
Pull deliniated text strings into a "SELECT" statement in a form.
Categories : HTML and PHP, PHP, Strings
Text Wrapping
Categories : PHP, HTML and PHP, Strings
string justification align center text
Categories : Strings, PHP, HTML and PHP
Produces browser-safe strings while preserving HTML tags.
Categories : Strings, HTTP, 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
Simple script to passing persistent and growing array between recalls of one page (manipulate little stack).
Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables
Extract keywords from a string having words in " " count as one string.
Categories : PHP, Strings, Regexps, Search
Multiple Select box, Select multiple Items from Menu.List box
Categories : PHP, HTML and PHP, Beginner Guides
This script contains 2 functions: 1 to create html select object based on your own customer date format entry- "M d Y h:i.... etc". The second function processes the select object on submit back to unix time.
Categories : PHP, Calendar, Date Time, HTML and PHP
Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML -
Categories : PHP, Directories, FTP, Filesystem, HTML and PHP
Website colour changer
Categories : PHP, HTML and PHP, Date Time
A quick way set data from a form to a function or other places where you can lose scope.
Categories : PHP, HTML and PHP, Variables
Random Password Generator
Categories : PHP, Strings, Security