Page 1 of 1

Slicing a selection of text?

Posted: Mon May 24, 2004 9:01 pm
by Joe
I am in the process of making a user arena where you can view everyones user details. I have done the pagination 'Without all of the javascript' and I am now wondering how I can cut a large selection of text about 170 characters into about 25 characters. It sounds pretty ridiculous asking this but its for a good cause... Any help? The furthest I have got is chop() but that only slices 1 character from the end of a string from what I know...

Regards



Joe 8)

Posted: Mon May 24, 2004 9:07 pm
by jason
[php_man]substr[/php_man]

Code: Select all

<?php
$shorter_text = substr($text, 0, 25);
?>
?

Posted: Mon May 24, 2004 9:07 pm
by John Cartwright
You could do this

$text = substr($text, 0, 25); //returns first 25 characters

EDIT: GAHHHHHHH JASON YOU BEAT ME BY A HAIR!!!!!!!!!!!!!!!!

Posted: Mon May 24, 2004 9:23 pm
by Joe
Yeah thanks alot for the help. Worked a treat, ;)


Joe