Regex SEO Links: Technical Error
Posted: Fri Mar 19, 2010 12:41 pm
Hi,
I am working on a SEO Keyword linking script and i need help fixing a bug in my regex pattern.
Here is my pattern ($url can be any url):
Here is the text the pattern is having problems with:
The Problem:
The first occurrence of "Salesforce Integration" does not get hyperlinked..
Can anyone help me out??
Thanks in advance,
Nik
I am working on a SEO Keyword linking script and i need help fixing a bug in my regex pattern.
Code: Select all
$keywordz = array("api integration salesforce integration","salesforce integration","api integration","web services");Code: Select all
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:
Code: Select all
<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>The first occurrence of "Salesforce Integration" does not get hyperlinked..
Can anyone help me out??
Thanks in advance,
Nik