主要是替换最为麻烦,因为里面牵涉到正则表达式。
一、文件的读写
//读取文件中的每一行
//将$str写到文件里
$fp1 = fopen($filename1,r);
$fp2 = fopetn($filename2,w+)
while (!feof($fp1))
$str = fgets($fp1);
fwrtie($fp2,$str);
二、随机数的生成
rand(1,100)
随机产生1-100之间的整数
三、替换
preg_replace():执行正则表达式的搜索和替换
preg_replace($pattern,$replacement,$str)
$pattern: 搜索的模式
$replacement:替换的字符
$str: 要进行搜索和替换的字符串
