TD Posted August 15, 2007 Share Posted August 15, 2007 Hi, could please someone tell me, how can i limit the echo chars from database, example, i have in table a row where is many text written, but i need only to echo first 150 chars. $sql = mysql_query("SELECT * FROM $tab where (val=$vid and $subisa and $subisb and $subisc and $subisd) order by title asc limit $limitvalue, $user_view_limit"); while($r=mysql_fetch_array($sql)) { $title=$r["title"] ; $text=$r["content"] ; echo "<h2>$title</h2>"; echo "<br/><h3>$text</h3>"; Quote Link to comment https://forums.phpfreaks.com/topic/65026-solved-how-to-limit-chars/ Share on other sites More sharing options...
MadTechie Posted August 15, 2007 Share Posted August 15, 2007 echo substr($r["content"], 0, 150); substr Quote Link to comment https://forums.phpfreaks.com/topic/65026-solved-how-to-limit-chars/#findComment-324512 Share on other sites More sharing options...
pranav_kavi Posted August 15, 2007 Share Posted August 15, 2007 i suppose u can use str_split() method that can split the string into an array of characters.then echo the array contents till a limit of 150. Quote Link to comment https://forums.phpfreaks.com/topic/65026-solved-how-to-limit-chars/#findComment-324514 Share on other sites More sharing options...
TD Posted August 15, 2007 Author Share Posted August 15, 2007 it works many thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/65026-solved-how-to-limit-chars/#findComment-324518 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.