drisate Posted August 12, 2010 Share Posted August 12, 2010 Hey guys i am trying to replace all the links in a var in to something else ... Ex: http://google.com into http://mywebsite.ca?email=XX_EMAIL&nid=XX_ID&dat=http://google.com What i have so fare is function matche($matches){ $url = str_replace('http://', '', $matches[1]); $url = str_replace('www.', '', $url); return 'href="http://maplaza.ca?email=XX_EMAIL&nid=XX_ID&dat='.$url.'"'; } $messages = preg_replace_callback("/href=['\"]([^'\"]+)['\"]/","matche",html_entity_decode($messages)); But for some reason it's not matching any link ... Ex of texte in $messages after html_entity_decode : <table width="100%"> <tbody> <tr> <td valign="top" height="20" align="center"><a href="http://mywebsite.ca/index.php" target="_blank"> <font face="verdana" color="white" size="2"> Politique de confidentialité</font></a></td> </tr> <tr> <td valign="top" height="20" align="center"><a href="http://mywebsite.ca/index.php?pageid=147&mod=nousjoindre" target="_blank"> <font face="verdana" color="white" size="2"> Communiquer avec nous</font></a></td> </tr> <tr> <td valign="top" height="20" align="center"><a href="http://mywebsite.ca/index.php?pageid=158" target="_blank"> <font face="verdana" color="white" size="2"> Annoncer sur mywebsite.ca</font></a></td> </tr> </tbody> </table> As you can see http://mywebsite.ca/index.php?pageid=158 should be transformed into http://mywebsite.ca?email=XX_EMAIL&nid=XX_ID&dat=mywebsite.ca/index.php?pageid=158 Any help would be apreciated... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.