PHP-STI Posted July 17, 2013 Share Posted July 17, 2013 I have over 2600 rows of text I need to loop through and add a title attribute in the link from the exisiting linked text to meet ADA compliance. For example: Input string Jack and Jill went up the hill to have a little fun,but stupid Jill forgot <a href="http://www.plannedparenthood.org/health-topics/birth-control/birth-control-pill-4228.htm">the pill</a>and now they have a son! Output string Jack and Jill went up the hill to have a little fun,but stupid Jill forgot <a title="the pill" href="http://www.plannedparenthood.org/health-topics/birth-control/birth-control-pill-4228.htm">the pill</a>and now they have a son! Does anyone know how I can use preg_match_all and str_replace or anything else to accomplish this? Thanks!!! Quote Link to comment https://forums.phpfreaks.com/topic/280237-need-to-add-title-in-links-for-ada/ Share on other sites More sharing options...
cyberRobot Posted July 17, 2013 Share Posted July 17, 2013 Have you considered using PHP's DOMDocument class? Quote Link to comment https://forums.phpfreaks.com/topic/280237-need-to-add-title-in-links-for-ada/#findComment-1441054 Share on other sites More sharing options...
PHP-STI Posted July 17, 2013 Author Share Posted July 17, 2013 Thanks, cyberRobot Yes, I did look into using DOMDocument, but I didn't feel it would have worked for my website. The text in the DB is the only issue because all of my navs and other dynamic pages are already coded with the title attribute. Quote Link to comment https://forums.phpfreaks.com/topic/280237-need-to-add-title-in-links-for-ada/#findComment-1441068 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.