-
-
/** - * Replacement of content keywords
- * edit: WWW.JBXUE.COM
- */
$ci=array("Short URL"=>"http:// jbxue.com","URL shortening"=>"http://jbxue.com");
//The content field is content
- $content="Shortening URL is a good tool" ;
- foreach($ci as $k=>$v){
- $str=''.$k.' a>';
- $content=ereg_replace($k,$str,$content);
- }
- echo $content;
-
Copy code
Attached, keyword replacement in empire cms Code:
-
- //Replace keyword
- function ReplaceKey($newstext){
- global $empire,$dbtbpre,$public_r;
- if(empty($newstext))
- {return $newstext; }
- $sql=$empire->query("select keyname,keyurl from {$dbtbpre}enewskey order by length(keyname) desc"); //Sort by length of field content
- while($r=$empire-> ;fetch($sql))
- {
- $newstext=empty($public_r[repkeynum])?str_replace($r[keyname],''.$r[keyname].'',$newstext):preg_replace('/'.$r[keyname].'/',''.$r[keyname].'',$newstext,$public_r[repkeynum]);
- }
- return $newstext;
- }
Copy code
|