一个文件中的字符串是否存在于另一个文件中
String in one file whether present in another file or not
我想查找一个文件中是否存在另一个文件中的字符串。
例如:file.txt包含->
IamLookingforthispatternpleasehelpme
pattern.txt->
这个模式
<?php
if(strpos(file_get_contents("file.txt"),file_get_contents("pattern.txt"))!=FALSE){
echo "found it!!";
}
else{
echo "not able to find";
}
?>
我写了上面的代码 运行 但它输出
"not able to find"
如何操作 我是新手 php
并澄清 txt 文件仅包含上述格式的文本。
文件 pattern.txt
文件可能包含阻止成功匹配的不可见字符。
考虑使用 bin2hex(file_get_contents("file.txt"))
和 bin2hex(file_get_contents("pattern.txt"))
对字符串值进行十六进制转储,并比较模式的十六进制字符串是否实际包含在文件的十六进制字符串中,这很可能不会案.
我想查找一个文件中是否存在另一个文件中的字符串。
例如:file.txt包含->
IamLookingforthispatternpleasehelpme
pattern.txt->
这个模式
<?php
if(strpos(file_get_contents("file.txt"),file_get_contents("pattern.txt"))!=FALSE){
echo "found it!!";
}
else{
echo "not able to find";
}
?>
我写了上面的代码 运行 但它输出
"not able to find"
如何操作 我是新手 php
并澄清 txt 文件仅包含上述格式的文本。
文件 pattern.txt
文件可能包含阻止成功匹配的不可见字符。
考虑使用 bin2hex(file_get_contents("file.txt"))
和 bin2hex(file_get_contents("pattern.txt"))
对字符串值进行十六进制转储,并比较模式的十六进制字符串是否实际包含在文件的十六进制字符串中,这很可能不会案.