PHP-Function rewrite htmlsource
$30-5000 USD
Paid on delivery
The function should take a html-source-string and replace parts of it according to the information given in a second parameter (array).
## Deliverables
This should be a easy for an experienced php-programmer.
**PHP-Version: 5.2**
The function should take a html-source-string and replace parts of it according to the information given in a second parameter (array):
The Array contains the following fields/information:
* **'searchpattern'** : a regular expression whose matches in the html-source should be replaced according to the following rules:
* **'replacepattern'**: the matching regular expression computing the replacement string - or empty if no replacement should be done
* **'link' ** : an URL the resulting pattern (or the original if 'replacepattern' is empty ) should be linked to - or nothing if empty
* **'start' ** : the # of the occurance that should be replaced (i.e. 3 => don't replace the first two occurances) - default: 1
* **'skip'** : the # of occurances that should be skipped after the first replacement (i.e. 1 - skip 1 then replace the next then skip 1 again and so on...) default: -1 (special value: only once!)
* **'casesensitive'** : if true the regular expression should be case sensitive, if false not - default: true
* **'fullwordsonly'** : if true only fullwords should be replaced, if false also parts of words should be replaced - default: true
and should the replacement string be part of another searchpattern match it should not be counted as such!
*Example: source: "*abc def ghi jkl*", first searchpattern:* def*, first replacement:* jkl*, second searchpattern:* jkl*, second replacement:* xyz*, the result should be: "*abc jkl ghi xyz*"
*
There are two more rules to obey:
* Never! replace strings within an URL (within an a-tag)
*Example: source: 'whatever <a href="[url removed, login to view]">abc</a> and some more...', searchpattern: abc, replacement: xyz, then the result should be: 'whatever <a href="[url removed, login to view]">xyz</a> and some more...'*
* Don't wrap a link around the result if it's already in a link
*Example: source: 'whatever <a href="[url removed, login to view]">abc jolly be good</a> and some more jolly ...', searchpattern: jolly, replacement: xyz, and link: [url removed, login to view] then the result should be: 'whatever <a href="[url removed, login to view]">abc xyz be good</a> and some more <a href="[url removed, login to view]">xyz</a>* ...'
Upon Agreement I will provide more testing examples (including the desired results)
Project ID: #3046132