Forum Moderators: coopster
I'm retrieving data from a mysql database, and lets say someone enters a few paragraphs of text. Lets say it has about 2000 characters. I want to be able to display only "x" amount of characters, lets say "x" equals 300. So It only displays 300 characters instead of 2000 characters.
If that makes any since please help.
echo substr($string,0,300);
However, if it was me I would let the database do the work with its own similar function:
$query = mysql_query("SELECT SUBSTRING('field',1,300) AS new_string FROM table...
$row = mysql_fetch_object($query);
echo $row->new_string;
Note that the pointer starts at 1 for mysql and not 0. More info here:
[dev.mysql.com...]
Good luck.
dc