Function to split the words of a string with invisible chars
Function to split the words of a string with invisible chars
function trunk($texto) {
$largomax = 10;
$arrayTexto = explode(' ',$texto);
$texto2='';
for($n=0;$n<count($arrayTexto);$n++) {
if (strlen($arrayTexto[$n])>$largomax) {
$palabra = '';
$l = 0;
for($x=0;$x<=strlen($arrayTexto[$n]); $x++) {
$letra = substr($arrayTexto[$n],$x,1);
$num = ord($letra);
$l++;
if ($l > $largomax) {
$letra = $letra . '​';
$l = 0;
} else {
if (($num > 47 && $num < 58) || ($num > 64 && $num < 91) || ($num > 96 && $num < 123)) {
$letra = $letra;
} else {
$letra = $letra . '​';
$l = 0;
}
}
$palabra = $palabra . $letra;
}
} else {
$palabra = $arrayTexto[$n];
}
$texto2 = $texto2 . ' '.$palabra;
}
return $texto2;
}
By Efra, published on October 31, 2010
http://www.phpzend.net
http://www.phpzend.net