Requested by Commenter: dawoodzai
Original Post: Limit Characters in a PHP String
So I just got a comment from dawoodzai asking if I could turn the Limit Characters in a PHP String article into a php function, well it was more like “I want to convert this to a function, … Thanks”, anyway… I made it into a function and added 2 new features, Preserve Tags and Auto Close Open Tags. Preserve Tags is my function/logic but I have to give credit to Jamie Wilkinson and the Code Snippet from CodeSnippets.Joyent.com for his auto detect and close tags function [ JamieW's Code Snippets Profile ].
Other resources
- Limit the middle characters of a string – Useful for preview of unimportant text (reminds me of firebug)
- Limit length of a text by not cutting full words – It’s my function on steroids and it doesn’t cut up the last word. However the number of characters will very from string-to-string