I have hyperlinks entered by users that have been justified. This has created the following scenario in my html:
<a href="http:// www. web site link .com ">Website link bro ken </a>
How can I use php to fix this on page load or in a script I run on my database to achieve this:
<a href="http://www.websitelink.com">Website link bro ken</a> (the link text I guess is impossible to fix without checkning if parts of words could fit together - as long as the link works, the on screen justification will have to pass.
Please bear in mind that these occurances are within large bodies of text. So searching for the spaces would begin with finding each link and then ‘repairing’ it.
function replaceSpaces( $in ) { return preg_replace( "/ /", "", $in ); } $link = preg_replace( "/href=\"[^\"]+\"/ie", " replaceSpaces( '\$0' )", $link );Edited – thx for comments – my mistake