Forum Moderators: coopster

Message Too Old, No Replies

trimming dynamic text in php

         

myacidpacemaker

3:14 am on Aug 3, 2005 (gmt 0)

10+ Year Member



hey,

im relatively new to php & have no idea how to trim dynamic text pulled from a db. im building a news section on a site & only want a small snippet of the news item to be displayed and then '... more' link which would link to the detail page.

this was discussed in the .net/asp forum at
[webmasterworld.com...]

which is exactly want i want to achieve, just in the wrong language.

thnx 4 your help.

chrisjoha

6:20 am on Aug 3, 2005 (gmt 0)

10+ Year Member



[php.net...]

$text = "This is a very long piece of text";
print(substr($text, 0, 10) . '... more');

Will output

This is a ... more

myacidpacemaker

10:11 am on Aug 3, 2005 (gmt 0)

10+ Year Member



cheers, just what i was after

kamakaze

11:39 am on Aug 3, 2005 (gmt 0)

10+ Year Member



Ah the great ol' substr. It is very useful. I use something very similar on my website. Works great for "Recent News" section.

[edited by: jatar_k at 4:48 pm (utc) on Aug. 3, 2005]