php strip_tags and preserve separation -


i parse this:

<p>   text1   <b>text2 text3</b>   text4 <p><br> text5 

into array:

[   "text1",    "text2 text3",    "text4",    "text5" ] 

currently using strip_tags provides less detailed:

"text1 text2 text3 text4 text5" 

what better approach desired result?

my application email processing. i'd little digraph , trigraph analysis not want pick graphs across html element boundaries.

use tags delimeters split, trim result , remove empty strings

$array = array_filter(array_map('trim', preg_split('/<[^>]+>/', $str))); 

result

array (     [1] => text1     [2] => text2 text3     [3] => text4     [5] => text5 ) 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -