-
-
$link = array( - 'Baidu,http://www.baidu.com/',
- 'Server software,http://s.jbxue.com /',
- 'Script Home, http://bbs.it-home.org/',
- );
- $str = 'Search for server software in Baidu to find the software provided by Script Home
- No longer wearing stockings in summer has become a fashion in recent years, even in autumn.
- Experts point out that this fashion is actually not conducive to beautiful legs. It is reported that sitting and standing for long periods of time, lack of exercise and other reasons can easily lead to varicose veins. Especially for people who stand and work for a long time, it is easy to cause the veins of the lower limbs to expand and lengthen, or the vein valves to be damaged and even cause disease. The specific manifestations include swelling of the legs, veins in the lower limbs bending like earthworms or forming nodules, and the skin becomes purple, especially on the inner side of the ankles and calves.
- Experts point out that people who stand and work for a long time have more or less varicose veins in the lower limbs, but the severity varies. Varicose veins of the lower limbs are a troublesome disease to treat, and severe cases require surgery. Therefore, the best way is to nip it in the bud. When the symptoms are not obvious, take preventive measures. Wearing long elastic stockings is one way. Great way to help get blood into larger, deeper veins.
- Maintaining an ideal weight can reduce the chance of varicose veins; avoid tight clothing and wear medical elastic stockings to avoid blood accumulation in the legs; be careful when taking birth control pills, as some birth control pills may cause this problem. ';
- $out=keylink($str,$link,1); //$str original character $link, replacement link array, 3 replacement times
- echo $out;
- function _sortDesc($a, $b) {
- return (strlen($a[0]) < strlen($b[0])) ? 1 : -1;
- }
- function keylink($str,$link,$count=1)
- {
- $linkDefs = $link;
- $linkMap = array();
- foreach($linkDefs as $row) {
- $linkMap[] = explode(',', $row);
- }
foreach ($linkMap as $row) {
- $str = preg_replace('/(s*)('.$row[0].')(s*)/sui ', '${2}', $str);
- }
usort($linkMap, '_sortDesc');
$tmpKwds = array( );
foreach($linkMap as $i=>$row) {
- list($kwd, $url) = $row;
- for($j=$i+1; $j$subKwd = $linkMap[$j][0];
- //If it contains other keywords, temporarily replace it with other strings
- if(strpos($kwd, $subKwd) !== false) {
- $tmpKwd = '{'.md5($subKwd).'}';
- $kwd = str_replace($subKwd, $tmpKwd, $kwd);
- $tmpKwds[$tmpKwd] = $subKwd;
- }
- }
- //Replace text with links
- $str = preg_replace('/('.$row[0].')/sui', ''.$kwd.'', $str, $count);
- }
//Replace sub Keyword string replacement
- foreach($tmpKwds as $tmp=>$kwd) {
- $str = str_replace($tmp, $kwd, $str);
- }
- return $str;
- }
- ?> ;
-
Copy code
|