小弟新手,大家看看代码有什么问题,测试部成功,谢谢了
<?php
if(is_readable("E:\usr\www\test.txt"))
{
echo "可读";
$file=fopen("E:\usr\www\test.txt","w");
}
else{
echo "worry";
}$string=fgets($file);$arry_specialchar=('0'=>'//t/', '1'=>'//n/', '2'=>'/~/', '3'=>'/!/', '4'=>'/@/', '5'=>'/#/', '6'=>'/$/', '7'=>'/^/', '8'=>'/&/', '9'=>'/*/', '10'=>'(/', '11'=>'/)/', '12'=>'/_/', '13'=>'/-/', '14'=>'/+/', '15'=>'/=/', '16'=>'/{/', '17'=>'/}/', '18'=>'/[/', '19'=>'/]/', '20'=>'/\/', '21'=>'/|/', '22'=>'/:/', '23'=>'/;/', '24'=>'/"/', '25'=>'/''/', '26'=>'/</', '27'=>'/>/', '28'=>'/,/', '29'=>'/./', '30'=>'///', '31'=>'/?/', '32'=>'/`/', '33'=>'/~/', '34'=>'/!/', '35'=>'/@/', '36'=>'/#/', '37'=>'/¥/', '38'=>'/……/',
'39'=>'/&/', '40'=>'/*/', '41'=>'/(/', '42'=>'/)/', '43'=>'/——/', '44'=>'/-/', '45'=>'/+/', '46'=>'/=/',
'47'=>'/{/', '48'=>'/}/', '49'=>'/【/', '50'=>'/】/', '51'=>'/、/', '52'=>'/|/', '53'=>'/:/', '54'=>'/;/',
'55'=>'/“/', '56'=>'/’/', '57'=>'/《/', '58'=>'/》/', '59'=>'/,/', '60'=>'/。/', '61'=>'/、/', '62'=>'/?/',
'63'='/`/' );for($i=0;$i<63;$i++)
{
$new_string=preg_replace("$arry_specialchar['$i']","$.$i","$string");
}for($j=0;$j<63;$j++)
{
$new_2string=preg_replace("/$.$j/","@.$j","$new_string");
}
echo "$new_2string";
if(fclose("E:\usr\www\test.txt"))
{echo trueth;}
?>
第一次发帖,有不足之处各位大侠见谅,帮忙看看
<?php
if(is_readable("E:\usr\www\test.txt"))
{
echo "可读";
$file=fopen("E:\usr\www\test.txt","w");
}
else{
echo "worry";
}$string=fgets($file);$arry_specialchar=('0'=>'//t/', '1'=>'//n/', '2'=>'/~/', '3'=>'/!/', '4'=>'/@/', '5'=>'/#/', '6'=>'/$/', '7'=>'/^/', '8'=>'/&/', '9'=>'/*/', '10'=>'(/', '11'=>'/)/', '12'=>'/_/', '13'=>'/-/', '14'=>'/+/', '15'=>'/=/', '16'=>'/{/', '17'=>'/}/', '18'=>'/[/', '19'=>'/]/', '20'=>'/\/', '21'=>'/|/', '22'=>'/:/', '23'=>'/;/', '24'=>'/"/', '25'=>'/''/', '26'=>'/</', '27'=>'/>/', '28'=>'/,/', '29'=>'/./', '30'=>'///', '31'=>'/?/', '32'=>'/`/', '33'=>'/~/', '34'=>'/!/', '35'=>'/@/', '36'=>'/#/', '37'=>'/¥/', '38'=>'/……/',
'39'=>'/&/', '40'=>'/*/', '41'=>'/(/', '42'=>'/)/', '43'=>'/——/', '44'=>'/-/', '45'=>'/+/', '46'=>'/=/',
'47'=>'/{/', '48'=>'/}/', '49'=>'/【/', '50'=>'/】/', '51'=>'/、/', '52'=>'/|/', '53'=>'/:/', '54'=>'/;/',
'55'=>'/“/', '56'=>'/’/', '57'=>'/《/', '58'=>'/》/', '59'=>'/,/', '60'=>'/。/', '61'=>'/、/', '62'=>'/?/',
'63'='/`/' );for($i=0;$i<63;$i++)
{
$new_string=preg_replace("$arry_specialchar['$i']","$.$i","$string");
}for($j=0;$j<63;$j++)
{
$new_2string=preg_replace("/$.$j/","@.$j","$new_string");
}
echo "$new_2string";
if(fclose("E:\usr\www\test.txt"))
{echo trueth;}
?>
第一次发帖,有不足之处各位大侠见谅,帮忙看看
解决方案 »
- {dede:loop}的问题
- array_walk的使用
- 新手请教PHP概念的问题
- jpgraph error 报错信息
- 正则表达式中的?,出现一点疑问
- firfox下是不是obj.focus()无效?
- 怎么用正则把百度空间的分类读成一个数组呢?代码如下.
- set_magic_quotes_runtime 对哪些数据或行为产生作用?当magic_quotes_gpc为on的话,print 表单变量,必须手动stripslashes吗?
- 帮我看看这个错误是什么意思?apache 的log.txt文件中的。数据库是mysql
- onchange 的疑问,如何在下拉框改变时更新数据库??急急急急!!!
- xdebug调试时崩溃怎么办?
- 蛋疼的新手又来求助前辈了。。同一页面处理post。。
如果是这个地方错了 其他地方没看
$arry_specialchar = array(...);
问问题给个错误提示嘛 贴个代码实在晕
'39'=>'/&/', '40'=>'/*/', '41'=>'/(/', '42'=>'/)/', '43'=>'/——/', '44'=>'/-/', '45'=>'/+/', '46'=>'/=/',
'47'=>'/{/', '48'=>'/}/', '49'=>'/【/', '50'=>'/】/', '51'=>'/、/', '52'=>'/|/', '53'=>'/:/', '54'=>'/;/',
'55'=>'/“/', '56'=>'/’/', '57'=>'/《/', '58'=>'/》/', '59'=>'/,/', '60'=>'/。/', '61'=>'/、/', '62'=>'/?/',
'63'=>'/`/');
for($i=0;$i<63;$i++)
{
$new_string=preg_replace("$arry_specialchar[$i]","$.$i",$string);
}
自己测试下
<?php
if(is_readable("E:\usr\www\test.txt"))
{
echo "可读";
$file=fopen("E:\usr\www\test.txt","w");
}
else{
echo "worry";
}$string=fgets($file);$arry_specialchar=('0'=>'//t/', '1'=>'//n/', '2'=>'/~/', '3'=>'/!/', '4'=>'/@/', '5'=>'/#/', '6'=>'/$/', '7'=>'/^/', '8'=>'/&/', '9'=>'/*/', '10'=>'/(/', '11'=>'/)/', '12'=>'/_/', '13'=>'/-/', '14'=>'/+/', '15'=>'/=/', '16'=>'/{/', '17'=>'/}/', '18'=>'/[/', '19'=>'/]/', '20'=>'/\/', '21'=>'/|/', '22'=>'/:/', '23'=>'/;/', '24'=>'/"/', '25'=>'/''/', '26'=>'/</', '27'=>'/>/', '28'=>'/,/', '29'=>'/./', '30'=>'///', '31'=>'/?/', '32'=>'/`/', '33'=>'/~/', '34'=>'/!/', '35'=>'/@/', '36'=>'/#/', '37'=>'/¥/', '38'=>'/……/',
'39'=>'/&/', '40'=>'/*/', '41'=>'/(/', '42'=>'/)/', '43'=>'/——/', '44'=>'/-/', '45'=>'/+/', '46'=>'/=/',
'47'=>'/{/', '48'=>'/}/', '49'=>'/【/', '50'=>'/】/', '51'=>'/、/', '52'=>'/|/', '53'=>'/:/', '54'=>'/;/',
'55'=>'/“/', '56'=>'/’/', '57'=>'/《/', '58'=>'/》/', '59'=>'/,/', '60'=>'/。/', '61'=>'/、/', '62'=>'/?/',
'63'=>'/·/' );for($i=0;$i<63;$i++)
{
$new_string=preg_replace("$arry_specialchar['$i']","$.$i","$string");
}for($j=0;$j<63;$j++)
{
$new_2string=preg_replace("/$.$j/","@.$j","$new_string");
}
echo "$new_2string";
if(fclose("E:\usr\www\test.txt"))
{echo trueth;}
?>打开时该网页无法显示我就是把64个特殊符号两次替换,第一次是$0-$63,第二次是$0-$63,不晓得什么地方出问题了?
{
return preg_replace(”/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/”,”,$s);
}替换不能显示的特殊字符的.