Forum Moderators: coopster

Message Too Old, No Replies

limit string length

         

Pico_Train

7:22 pm on May 15, 2008 (gmt 0)

10+ Year Member



Hi!

Say I have a string in an array that is 2000 characters long but I only want to display the first 100 characters.

Is there a php function that does that sort of thing or a combination of functions I can use together to do it?

Thanks!

dreamcatcher

7:25 pm on May 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



echo substr [uk.php.net]($string,0,100);

dc

Pico_Train

7:28 pm on May 15, 2008 (gmt 0)

10+ Year Member



Nice one, cool thanks! I might have a few more like this coming as my knowledge of functions is limited at the moment.

[edited by: Pico_Train at 7:30 pm (utc) on May 15, 2008]

dreamcatcher

8:00 am on May 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Its worth taking a look at the string functions on the PHP website. There you can see working examples and get a feel for how some of them work. You won`t use all of them during your programming life, but many are huge time savers.

dc