djstaz0ne Posted March 19, 2010 Share Posted March 19, 2010 Hi, I am working on a SEO Keyword linking script and i need help fixing a bug in my regex pattern. $keywordz = array("api integration salesforce integration","salesforce integration","api integration","web services"); Here is my pattern ($url can be any url): for($i=0;$i<count($keywordz);$i++){ $pattern = '!(<[^a][^>]*>[^<]*)('.$keywordz[$i].')!i'; $replacement = '$1<a href="/'.$url.'">$2</a>'; $text = preg_replace($pattern, $replacement, $text); } Here is the text the pattern is having problems with: <h1>Salesforce Integration and API Integration in New York</h1> <p>Perpetual Technologies Unltd. specializes in api integration and Salesforce Integration in New York City. We have extensive experience in integrating CRM Systems with additional corporate data, utilizing web services APIs - working with SOAP and PHP. We can connect your "online work requests" to salesforce, automatically storing them in a database, and automatically generating and emailing "job tickets", listing all relevant project-related information. Salesforce Integration will help your company operate more smoothly.</p> URL: http://perpetualtechnologies.net/salesforce-integration/api-integration.htm The Problem: The first occurrence of "Salesforce Integration" does not get hyperlinked.. Can anyone help me out?? Thanks in advance, Nik Quote Link to comment Share on other sites More sharing options...
djstaz0ne Posted March 19, 2010 Author Share Posted March 19, 2010 Solved: http://forums.devnetwork.net/viewtopic.php?f=38&t=114403 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.