質問編集履歴

1

文法の修正

2021/01/26 15:09

投稿

tundorian-hamu
tundorian-hamu

スコア42

test CHANGED
File without changes
test CHANGED
@@ -23,91 +23,3 @@
23
23
  何を調べれば、何を理解すれば上記の問題が解決するでしょうか。
24
24
 
25
25
  また、君は***がわかっていない。などアドバイスを頂ければ嬉しいです。
26
-
27
-
28
-
29
- **やってみたこと**
30
-
31
- 元々は下記のようにしておりました。
32
-
33
- ```php
34
-
35
- $day1 = isset($argv[2]) ? $argv[2] : null;
36
-
37
- $day2 = isset($argv[3]) ? $argv[3] : null;
38
-
39
- $day3 = isset($argv[4]) ? $argv[4] : null;
40
-
41
- ```
42
-
43
-
44
-
45
- ```php
46
-
47
- <?php
48
-
49
- //targetは調べる単語
50
-
51
- $target = $argv[1];
52
-
53
- $days = [];
54
-
55
- $days = [
56
-
57
- $argv[2],
58
-
59
- $argv[3],
60
-
61
- ];
62
-
63
- function test($target,$days) {
64
-
65
- foreach ($days as $day) {
66
-
67
- $file = "{$day}.txt";
68
-
69
- if(!file_exists($file)){
70
-
71
- continue;
72
-
73
- }
74
-
75
- $fpr = fopen($file,"r");
76
-
77
- $fpw = fopen("{$file}_count.txt","w");
78
-
79
- while ($line = fgets($fpr)) {
80
-
81
- $pattern = "/^((?!{$target}).)*$\n/m";
82
-
83
- $Replace = preg_replace($pattern,'',$line);
84
-
85
- $pattern2 = "/Request: (.+)&/m";
86
-
87
- preg_match($pattern2,$Replace, $matches);
88
-
89
- if(empty($matches[1])) {
90
-
91
- continue;
92
-
93
- }else {
94
-
95
- fwrite($fpw, $matches[1]."\r\n");
96
-
97
- }
98
-
99
- }
100
-
101
- fclose($fpr);
102
-
103
- fclose($fpw);
104
-
105
- }
106
-
107
- }
108
-
109
- test($target, $days);
110
-
111
- ?>
112
-
113
- ```