<?php

/*
 * Example function to take in a string, look for words bigger than a certain size
 * and insert a character to break them up.
 *
 * Paul Gregg
 * Sat 15th Jan 2005
 */

Function wordwrap_bigwords($in_string$max_wordsize$sepchar=" ") {
  
$DEBUG false;
  
$words preg_split('|(\s)|'$in_string, -1PREG_SPLIT_DELIM_CAPTURE);
  
$i=0;
  foreach(
$words as $word) {
    if (
$DEBUG) print "Processing '$word'";
    if (
strlen($word) > $max_wordsize) {
      
$words[$i] = wordwrap($word$max_wordsize$sepchar1);
      if (
$DEBUG) print " splitting word to '"$words[$i] ."'";
    }
    if (
$DEBUG) print "\n";
    
$i++;
  }
  return 
implode(''$words);
}

$test "Hello there. This is a longish string withaverylongwordinthemiddletobechopped.\n";

print 
"<pre>\n";
print 
"Before: $test\n";
print 
"After : " wordwrap_bigwords($test10' ');
print 
"\n";

print 
"<hr><br>Date of file: " date ("d F Y H:i:s."getlastmod());
?>