Hi at the moment I'm using this function to add spaces into words longer than 11 characters in a string

<?php
function($text) {
  $words=explode(' ',$text);
  for($i=0; $i<count($words); $i++) {
    if(strlen($words[$i])>11) {
      $words[$i]=substr($words[$i],0,10)." ".substr($words[$i],10);
    }
  }
  $text=implode(' ', $words);
  return $text;
}
?>

which works fine. However I was wondering if this could be accomplished with regular expressions?
Thanks
Rob

    Write a Reply...