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
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 : textwrap fill-paragraph
Categories : Strings, PHP, Algorithms Update Picture
Michael Guravage
Date : Jul 15th 1998
Grade : Be the 1st to grade this Code Example
Viewed : 3856
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Michael Guravage
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

//Algorithm contributed by Richard Lynch at <lynch@lscorp.com>
Function fill_paragraphs($text, $wrap=80, $break="\n") {
// break the text into paragraphs by stripping off any newline characters
$paragraphs = split("\n+", "$text");

// format one paragraph at a time
for ($i = 0; $i < sizeof($paragraphs); $i++) {
$paragraphs[$i] = textwrap($paragraphs[$i], $wrap, $break);
}
// concatenate the formatted paragraphs into a single string
// with a newline character between each element
return implode("\n", $paragraphs);
}


// Contributed by Richard Lynch: <lynch@lscorp.com>.
Function textwrap($text, $wrap=80, $break="\n"){
$len = strlen($text);
if ($len > $wrap){
$h = ''; // massaged text
$lastWhite = 0; // position of last whitespace char
$lastChar = 0; // position of last char
$lastBreak = 0; // position of last break

// while there is text to process
while ($lastChar < $len){
$char = substr($text, $lastChar, 1); // get the next character

// if we are beyond the wrap boundry and there is a place to break
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; // note the position of the last white space
}
$lastChar = $lastChar + 1; // advance the last character position by one
}
$h .= substr($text, $lastBreak); // build line
}
else{
$h = $text; // in this case everything can fit on one line
}
return $h;
}



The Porter Word Stemming Algorithm in PHP Reduces words to their base stem for search engines and indexing
Categories : Algorithms, PHP, Strings
textwrap fill-paragraph (justification)
Categories : Strings, PHP, Algorithms
Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET
Categories : Algorithms, HTML and PHP, PHP, Variables
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
mysql_escape_string
Categories : PHP, MySQL, Databases, Strings
Allows you to parse a deliniated string and put the individual fields in a SELECT option in a form
Categories : HTML, PHP, Strings
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
Adding dashes to credit card numbers
Categories : Strings, Credit Cards, PHP
Boolean Keyword Interpreter
Categories : PHP, Algorithms, Search Engines
I need a trim function/regexp that will trim all " " from the ends of a string.
Categories : Regexps, PHP, Strings
Diffusion-Limited Aggregation visualization
Categories : PHP, Graphics, Algorithms, Math.
Customizable encoding and decoding strings with security.
Categories : PHP, Strings, HTML and PHP
Printer friendly pages from anywhere on a website.
Categories : PHP, Strings, Content Management
Browse a MySQL database & draw a tree view & load final items into a template page.
Categories : MySQL, Complete Programs, Algorithms, PHP, Databases
Recursive function to move files on a filesystem. It can be minor changed in order to copy recursively.
Categories : PHP, Filesystem, Algorithms