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

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -