PHP string manipulation
-
Okay, here’a good one to test the PHP coders amoung us.
I want to read $post_content from a post and display only a portion of it if it exceeds a certain length (we’ll say 1000 characters). But, I’m freaked out about just using this: echo(substr($post_content,0,999)); …because I don’t want it to cut off in the middle of an xhtml tag (or something equally error promising).
I had thought about iterating through $page_content and counting the ‘<‘ and ‘>’ (much like a running stack variable or counting 10’s in Black Jack)… but I still may end up cutting off before a beginning tag has goten to its ending tag.
Any ideas?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘PHP string manipulation’ is closed to new replies.