NorthWestSimulations Posted May 9, 2008 Share Posted May 9, 2008 How to I make a function to only allow a word to be 32 letters long? the reason I am doing this is because the ?page= will display the value on the screen as $page = mysql_real_escape_string(htmlspecialchars($_GET['page'])); so when they use alot of letters it throws the HTML off balance. Is there a way of making it so that if a word is like 45 charactors long only the first 32 will appear? Link to comment https://forums.phpfreaks.com/topic/104929-solved-long-words-hurt-my-site/ Share on other sites More sharing options...
radar Posted May 9, 2008 Share Posted May 9, 2008 if (strlen($summary) > $limit) $summary = substr($summary, 0, strrpos(substr($summary, 0, $limit), ' ')) . '...'; echo $summary; Link to comment https://forums.phpfreaks.com/topic/104929-solved-long-words-hurt-my-site/#findComment-537115 Share on other sites More sharing options...
NorthWestSimulations Posted May 9, 2008 Author Share Posted May 9, 2008 Ahh this works: $page = substr(mysql_real_escape_string(htmlspecialchars($_GET['page'])), 0, 32); Link to comment https://forums.phpfreaks.com/topic/104929-solved-long-words-hurt-my-site/#findComment-537119 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.