Skip to content

Instantly share code, notes, and snippets.

@xianhuazhou
Created May 19, 2010 03:08
Show Gist options
  • Save xianhuazhou/405904 to your computer and use it in GitHub Desktop.
Save xianhuazhou/405904 to your computer and use it in GitHub Desktop.
<?php
$str = '这是中国和中国的句子,把中国替换成其它的,把中国的替换成另一个';
$str = str_replace('中国的', '<a href="a.php"><中国的</a>', $str);
$str = preg_replace('/(中国)([^的])/', '<a href="b.php">$1</a>$2', $str) . "\n";
echo $str;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment