On Thursday 25 April 2002 00:14, Kirk Babb wrote:
> I have a feeling I am making this much harder than it really is! I'm a new
> programmer, and I am trying to output "x" number of characters per line
> without splitting up the words in the string. I want to approach as best
> as possible a cert
function wrap_lines ($str, $line_length)
{
$r = '';
$words = preg_split('/\s/', $str);
$cur_pos = 0;
foreach($words as $word)
{
if (($cur_pos + strlen($word) + 1) > $line_length)
{
$cur_pos = 0;
$r .= '';
}
else
{
$r .= ' ';
$cur_pos++;
I have a feeling I am making this much harder than it really is! I'm a new
programmer, and I am trying to output "x" number of characters per line
without splitting up the words in the string. I want to approach as best as
possible a certain number of characters per line, let's say 80 characters
3 matches
Mail list logo