conker87 Posted April 9, 2008 Share Posted April 9, 2008 I have a little blogging code that shows a little snippit (300 characters) of the blog and then a direct link to it. <php substr(strip_tags(nl2br($array['content']), "<img><br><br />"), "0", "300"); ?> Is the code I'm using. I'm wondering if I could modify the substr function (thus making my own function) to not count html tags as part of the number of characters shown. I'm sure this can be done, any ideas? Link to comment https://forums.phpfreaks.com/topic/100315-substr-to-ignore-tags/ Share on other sites More sharing options...
soycharliente Posted April 9, 2008 Share Posted April 9, 2008 $content = preg_replace('%<span class="foo">(.*?)</span>%sm', '\1', $content); that should return text with all tags stripped. Link to comment https://forums.phpfreaks.com/topic/100315-substr-to-ignore-tags/#findComment-512971 Share on other sites More sharing options...
cooldude832 Posted April 9, 2008 Share Posted April 9, 2008 this is a tricky problem. What I would do is simply full run strip_tags then get the text substr and then reapply formatting. Link to comment https://forums.phpfreaks.com/topic/100315-substr-to-ignore-tags/#findComment-512997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.