Dedecms software adds description Connection Methods in batches
Mysql tutorial _ connect ('localhost', 'root', 'root') or die ('database connect failer ');
Mysql_select_db ('M ');
Mysql_query ("set Names 'gb2312 '");
$ SQL = "Select aid, introduce from d_addonsoft order by aid desc limit 0, 2 ";
$ Query = mysql_query ($ SQL );
While ($ rs = mysql_fetch_array ($ query ))
{
$ Body = keywords ($ rs ['initduce '], $ array );
$ S = "Update d_addonsoft set introduce = '$ body' where aid =". $ rs ['aid'];
Mysql_query ($ s );
Echo $ body, '<br/> ';
}
$ Array = array (
Array ('A', '/bb /'),
Array ('cc', '111cnnet ')
);
$ Str = 'bb vector cc vector times ';
Echo keywords ($ str, $ array );
Function keywords ($ str, $ array)
{
$ Count = 0;
Foreach ($ array as $ v ){
Echo $ v [0], '<br/> ';
If (strstr ($ str, $ v [0])! = False ){
If ($ count <= 2 ){
$ Str = preg_replace ("/$ v [0]/", "<a href = ". $ v [1]. "target = _ blank> ". $ v [0]. "</a>", $ str, 1 );
$ Count ++;
Continue;
}
}
}
Return $ str;
}
?>