Chaos Project

General => Electronic and Computer Section => Programming / Scripting / Web => Topic started by: G_G on May 16, 2011, 11:27:04 am

Title: [PHP] Truncated Text Problem
Post by: G_G on May 16, 2011, 11:27:04 am
I'm trying to make my blog a bit better by having a page of posts and having it cut off after 300 characters then have a ...More thing. Anyways I've got it working for the most part until it hits a tag. Expected, PHP will only post the amount of text it should, the downside to this is that some tags won't get closed and other tags get messed up.

Does anyone know a way around this, or another way to try and do what I'm doing? Or maybe a script that will close off tags?
Title: Re: [PHP] Truncated Text Problem
Post by: Blizzard on May 16, 2011, 12:01:48 pm
You will have to parse it manually, keep track of open tags and close them manually after you cut everything off. I don't think there's a simple solution. Either that, or you restrict the text from having tags any other than <br />.