Explode a string to an array

GormthePeevish

New Member
Probably easy to do but I can't seem to generate the correct regex.Say I have this string\[code\]$string = '<h2>Header 1</h2><p>ahs da sdka dshk asd haks</p><img src="http://dummyimage.com/100x100/" width="100" height="100" alt="Alt" /><h2>Header 2</h2><p>asdkhas daksdha kd ahs</p><em>Lame</em><p>trhkbasd akhsd ka dkhas</p><h2>Header 3</h2><p>ajdas ahkds hakd</p>';\[/code\]And I need it like this\[code\]$array[0] = '<h2>Header 1</h2><p>ahs da sdka dshk asd haks</p><img src="http://dummyimage.com/100x100/" width="100" height="100" alt="Alt" />';$array[1] = '<h2>Header 2</h2><p>asdkhas daksdha kd ahs</p><em>Lame</em><p>trhkbasd akhsd ka dkhas</p>';$array[2] = '<h2>Header 3</h2><p>ajdas ahkds hakd</p>';\[/code\]...and so on if my string contains more of those H2 blocks.So, the split-point is at H2 and it needs to keep the HTML-tags. Any pointers?
 
Back
Top