I know this is easy, but I'm currently vexed...
I'm trying to get rid of any <br /> tags that occur before list tags (ul, ol, li, etc.), but it's getting rid of other <br /> tags I want to keep.
The code looks like:
$cleaned= preg_replace('/<br \/>([<ul>|<UL>|<\/ul>|<\/UL>|<ol>|<OL>|<\/ol>|<\/OL>|<li>|<LI>|<\/li>|<\/LI>])/', '\\1', $text);
An excerpt of source text might be:
<br /><li><strong>Customer Referrals</strong><br />Members information will be posted for clients on a page specific to your state and location.... to the general public.</li><br /><li><strong>Website Listing</strong><br />One of the most important ways ... database of qualified professionals.</li>
I'm trying to get rid of the <br /> tags preceding the <li> and </li> tags, and leave alone the ones that follow the </strong> tags above. The first one (Customer Referrals) is fine - the <br /> is left alone. But in the second (Website Listings) the <br /> tag following </strong> is replaced - not what I want.
The result looks like this:
<li><strong>Customer Referrals</strong><br />Members information will be posted for clients on a page specific to your state and location.... to the general public.</li><li><strong>Website Listing</strong>One of the most important ways ... database of qualified professionals.</li>
Naturally this is driving me batty, but I bet I'm just doing something stupid. Can anyone tell me what's wrong?