buknoii Posted March 27, 2008 Share Posted March 27, 2008 hi there! anyone in here got an idea on how to produce an output coming from the database wherein the output is limited to only 60 characters? for example i have a field named news_content and i want to display on 60 characters.. anyone in here got an idea? Link to comment https://forums.phpfreaks.com/topic/98127-getting-certain-number-of-characters/ Share on other sites More sharing options...
r-it Posted March 27, 2008 Share Posted March 27, 2008 use substring: substr($var, 0, 60); Link to comment https://forums.phpfreaks.com/topic/98127-getting-certain-number-of-characters/#findComment-501972 Share on other sites More sharing options...
buknoii Posted March 27, 2008 Author Share Posted March 27, 2008 how do i insert a substring on this kind of code? echo $row["content_data"]; Link to comment https://forums.phpfreaks.com/topic/98127-getting-certain-number-of-characters/#findComment-501974 Share on other sites More sharing options...
r-it Posted March 27, 2008 Share Posted March 27, 2008 it would be better to store the data in a variable first: $var = $row["content_data"]; $var = substr($var, 0, 60); echo $var; or echo substr($row["content_data"], 0, 60); Link to comment https://forums.phpfreaks.com/topic/98127-getting-certain-number-of-characters/#findComment-501977 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.