Reputation: 78
I want to add icon before link text. For example I have following links:
<a href="#" class="link-66">random text here</a>
<a href="#" class="link-67">another random text</a>
<a href="#" class="link-68">random text</a>
I would like to add Icon before link text:
<a href="#" class="link-66"><i class="icon" /> random text here</a>
<a href="#" class="link-67"><i class="icon" /> another random text</a>
<a href="#" class="link-68"><i class="icon" /> random text</a>
Now, How can do this in PHP?
Upvotes: 0
Views: 503
Reputation: 456
Replace the end of starting tag.
preg_replace('#(<a [^>]*>)#', '$1<i class="icon" />', $source);
Upvotes: 3