Wrap text !!
#1

hello,

How to cut a sentence without cutting word?

I wanted to take the logic of php but I do not see how to convert pawn

Код:
$maxchar= 20;
if (strlen($string) > $maxchar) 
 $string= substr($string, 0, $maxchar) ;
 $space= strrpos($string, " ") ;
 $string= substr($string, 0, $space)."..." ;

echo $string;
thanks !!
Reply
#2

Just an idea.

start to scan the row from the length you want to cut, and at first " " symbol split it.

Like you want that it sends msgs not longer than 128 symbols,

then just start to
pawn Код:
for(new i = 120; i < strlen(string); i++)
{
if(string[i] == ' ') { split at 130 for example; }
}
and you know at which place to split it.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)