具有特殊字符的PHP If语句
如何创建If语句或函数,使If找到特殊字符“}”,然后在下一个字符中放入具有特殊字符的PHP If语句,php,file-io,Php,File Io,如何创建If语句或函数,使If找到特殊字符“}”,然后在下一个字符中放入 $myfile = fopen("result.txt", "r") or die("Unable to open file!"); while(!feof($myfile)) { echo fgetc($myfile); } fclose($myfile); 您可以读取文件的内容,然后进行替换 $contents = file_get_contents('file.txt'); $contents = str
$myfile = fopen("result.txt", "r") or die("Unable to open file!");
while(!feof($myfile)) {
echo fgetc($myfile);
}
fclose($myfile);
您可以读取文件的内容,然后进行替换
$contents = file_get_contents('file.txt');
$contents = str_replace('}', '}<br>', $contents);
echo $contents;
如果要再次保存,可以按如下方式执行:
if ( ! file_put_contents('file.txt', $contents)) {
echo 'Error. File could not be saved!';
}
您可以读取文件的内容,然后进行替换
$contents = file_get_contents('file.txt');
$contents = str_replace('}', '}<br>', $contents);
echo $contents;
如果要再次保存,可以按如下方式执行:
if ( ! file_put_contents('file.txt', $contents)) {
echo 'Error. File could not be saved!';
}
您可以读取文件的内容,然后进行替换
$contents = file_get_contents('file.txt');
$contents = str_replace('}', '}<br>', $contents);
echo $contents;
如果要再次保存,可以按如下方式执行:
if ( ! file_put_contents('file.txt', $contents)) {
echo 'Error. File could not be saved!';
}
您可以读取文件的内容,然后进行替换
$contents = file_get_contents('file.txt');
$contents = str_replace('}', '}<br>', $contents);
echo $contents;
如果要再次保存,可以按如下方式执行:
if ( ! file_put_contents('file.txt', $contents)) {
echo 'Error. File could not be saved!';
}
将
}
替换为
?否,在字符之后,}将将
}
替换为}
,然后?如果找到特殊字符},它将更改行,如“\n”将
替换为
”否,字符}将放置一个替换
}
为}
之后,如果找到特殊字符},则它将更改行,如“\n”将}
替换为
否,字符}将放置一个替换
}
为}
之后,如果找到特殊字符},则它将更改行,如“\n”将}
替换为
否,在字符}之后,将放置一个替换
}
为}
然后?如果找到特殊字符},则它将像“\n”一样更改行