Jump to content

strlen


Dane

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.