Jump to content


Photo

Help with using trim *SOLVED*


  • Please log in to reply
2 replies to this topic

#1 crzyman

crzyman
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 16 September 2006 - 06:16 PM

I want to limit the amout of text that gets displayed from the database, which I can do using this statement:
$text = substr($message, 0, 80);
Now I am trying to display only 40 char per line. I thought this would work:
  $text = substr($message, 0, 80);
  $trim = trim($text, 0, 40, " \r.");

echo nl2br("$name\n $trim \n $time\n");
But that would of been to easy. Can someone please help me out? Many thanks.

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 16 September 2006 - 06:43 PM

<?php
$text = wordwrap(substr($message,0,80),40,"\r\n");
?>


#3 crzyman

crzyman
  • Members
  • PipPip
  • Member
  • 25 posts

Posted 16 September 2006 - 06:52 PM

Thanks! Works great.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users