The code is as follows:
<title>Four-bit. Club Domain</title>
/*
The contents of the Test.txt file are:
10ferents.club
1901.club
1992.club
288cash.club
2nd.club
365gold.club
3dscanning.club
406disco.club
99fitness.club
Abuo9i8n3.club
Abuo9i8n5.club
Abur5t6b2.club
Abut6y7n1.club
Abut6y7n4.club
Abut6y7n7.club
Abuy7u8n6.club
1234.club
Abcd.club
4.txt only:
Abcd.club
The correct answer should be:
1901.club
1992.club
1234.club
Abcd.club
*/
$handle =fopen ("Test.txt", "R");
while (!feof ($handle)) {
$str =fgets ($handle);
if (Stripos ($str, ".") ==4) {
File_put_contents ("4.txt", $str);
}
}
?>
Filter the domain name, but the results show only one line, with
echo $str. "
\ n "; display results in normal.
Reply content:
The code is as follows:
Four-bit. Club Domain
/*
The contents of the Test.txt file are:
10ferents.club
1901.club
1992.club
288cash.club
2nd.club
365gold.club
3dscanning.club
406disco.club
99fitness.club
Abuo9i8n3.club
Abuo9i8n5.club
Abur5t6b2.club
Abut6y7n1.club
Abut6y7n4.club
Abut6y7n7.club
Abuy7u8n6.club
1234.club
Abcd.club
4.txt only:
Abcd.club
The correct answer should be:
1901.club
1992.club
1234.club
Abcd.club
*/
$handle =fopen ("Test.txt", "R");
while (!feof ($handle)) {
$str =fgets ($handle);
if (Stripos ($str, ".") ==4) {
File_put_contents ("4.txt", $str);
}
}
?>
Filter the domain name, but the results show only one line, with
echo $str. "
\ n "; display results in normal.
Such
$str = fgets($handle); $str = trim($str);
Do not know how to solve the time, please
var_dump(stripos($str,"."));
See if it's 4.
There are also append writes:
file_put_contents("4.txt",$str, FILE_APPEND);
Wrote a demo, with regular matches.
$str = '10ferents.club 1901.club 1992.club 288cash.club 2nd.club 365gold.club 3dscanning.club 406disco.club 99fitness.club abuo9i8n3.club abuo9i8n5.club abur5t6b2.club abut6y7n1.club abut6y7n4.club abut6y7n7.club abuy7u8n6.club 1234.club abcd.club';preg_match_all('/[0-9a-z-]{4}/', $str, $arr);$string = implode("\n", $arr[0]);file_put_contents('1.txt', $string);
:
file_put_contents
Each time it is overwritten, it should be written with an fwrite
append
File_put_contents ("4.txt", $str, File_append);
fopen ("Test.txt", "a")