php - Skip html tags when searching for whitespace -
i have line of code here , $post['post']
string may contain html tags:
echo mb_strpos(mb_substr($post['post'], 299), " ");
i want find first occurrence of whitespace character 299th offset of $post['post']
, want ignore html tags. example, want ignore whitespace in following string:
<br />
how ignore whitespace inside such html tags?
you should use strip_tags
(more info here: http://php.net/manual/en/function.strip-tags.php):
echo mb_strpos(mb_substr(strip_tags($post['post']), 299), " ");
if want allow html tags, can here:
echo mb_strpos(mb_substr(strip_tags($post['post'], "<a><b><span>"), 299), " ");
Comments
Post a Comment