The PHP regular expression replaces the site keyword link and then solves the blank problem. The regular expression keyword. The PHP regular expression replaces the site keyword link with a blank space to solve the problem. The regular expression keyword title does not know whether it is appropriate or not. The specific situation is as follows: the website needs to add a PHP regular expression to replace the site keyword link. The problem is solved after the link is blank. the regular expression keyword
The title is inappropriate. The specific situation is as follows: the website needs to add the keyword link function, then it needs to match and replace the content of the article with a regular expression, and then uses the preg_replace function. The replaced program code is as follows:
Function ReplaceKeyword ($ linkDefs, $ content) {$ linkMap = array ();/* foreach ($ linkDefs as $ row) {$ linkMap [] = explode (',', $ row);} */$ linkMap = $ linkDefs; // replace the original link with the text foreach ($ linkMap as $ row) {$ content = preg_replace ('/(\ s *)('. $ row [0]. ') (\ s * <\/a>)/sui', $ row [0], $ content);} // sort usort ($ linkMap, '_ sortDesc'); // var_dump ($ linkMap); $ tmpKwds = array (); // store the temporarily replaced subkeyword $ k_count = 0; foreach ($ linkMap as $ I =>$ row) {list ($ kwd, $ url) = $ row; for ($ j = $ I + 1; $ j $ Kwd) {$ content = str_replace ($ tmp, $ kwd, $ content);} $ result = array ($ content, $ k_count); return $ result; unset ($ result); unset ($ tmp); unset ($ tmpKwds); unset ($ kwd); unset ($ count); unset ($ config ); unset ($ linkMap); unset ($ linkDefs); unset ($ tmpKwd); unset ($ content); unset ($ th_num); unset ($ row ); unset ($ k_count );
} The program is found on the Internet, and then tested locally. the local environment serves php 5.3 as 5.2. after uploading the program to the Internet, it is blank when submitted, the first consideration was the PHP version. I thought it was the difference between ereg preg and it would not work after replacement. Later, I checked it online and found that some netizens said they could adjust the large pcre. backtrack_limit and pcre. recursion_limit. I tried it and it was okay. It seems to be a configuration problem, but in general, the default configuration of PHP should be no problem, I wrote this program is still not good enough!
Php regular expression problem. Below is a program that replaces the keyword with the link
I can write it like this. I tried IE6 and FIREFOX 3.0. No problem.
New Document </TITLE>
</HEAD>
Xhtml Linux
</BODY>