Dane Posted December 24, 2007 Share Posted December 24, 2007 Hey guys, Im using the peice of code below to grab the first ## characters and then add a more... for the whole thing. However im using bbcode now and say for example i gets the first 170 and the end of the post looks like blah blah blah[/ ^^ it doesnt close the bold text bbcode therefore would look messy. Is there a way to make it so whole strings are not broken? if(strlen($website) <> 170 ) { $totalChars = 170; $website= substr($website,0,$totalChars)."...<a href=\"$website_feature_link/feature_more/$website_feature_id/\"><i>more</i></a>"; echo $website; } Link to comment https://forums.phpfreaks.com/topic/83029-strlen/ Share on other sites More sharing options...
predator Posted December 24, 2007 Share Posted December 24, 2007 Hey. if your capping the text at 170 characters then it will cut off what ever is the 171 and more. A way to get around this would be to see what the last 3 characters are and through an if statement check if they are == to [/i or [/b or something like that. then if they are add the extra ] to the string to close it. Regards mark Link to comment https://forums.phpfreaks.com/topic/83029-strlen/#findComment-422336 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.