PHP 8.5.0 Beta 1 available for testing

Voting

: min(one, five)?
(Example: nine)

The Note You're Voting On

Peter
18 years ago
The main concern when you have a text in a cell is for long words that drags the cell margins. This function will break words in a text that have more then $nr characters using the "-" char.

<?php
function processtext($text,$nr=10)
{
$mytext=explode(" ",trim($text));
$newtext=array();
foreach(
$mytext as $k=>$txt)
{
if (
strlen($txt)>$nr)
{
$txt=wordwrap($txt, $nr, "-", 1);
}
$newtext[]=$txt;
}
return
implode(" ",$newtext);
}
?>

<< Back to user notes page

To Top