回答編集履歴
1
差替えるソースに修正
test
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
$cnt = 0;
|
10
10
|
|
11
|
-
$delete =
|
11
|
+
$delete = 2;//削除したい番号
|
12
12
|
|
13
13
|
foreach ($file as $value) {
|
14
14
|
|
@@ -17,6 +17,8 @@
|
|
17
17
|
if($fileContent[0] == $delete){//削除したい番号と1つめのカラムが一致したら…(今回は1カラム目と想定)
|
18
18
|
|
19
19
|
unset($file[$cnt]);//一致した行を消す
|
20
|
+
|
21
|
+
array_splice($file, $cnt, 0,"4<>コンテンツ差し替え\n");
|
20
22
|
|
21
23
|
file_put_contents('log.txt',$file);//更新後の配列をfile_put_contentsで上書き
|
22
24
|
|
@@ -28,8 +30,36 @@
|
|
28
30
|
|
29
31
|
}
|
30
32
|
|
31
|
-
print "
|
33
|
+
print "コンテンツ差替えしました<br>";
|
32
34
|
|
33
35
|
?>
|
34
36
|
|
35
37
|
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
> 入力
|
42
|
+
|
43
|
+
```
|
44
|
+
|
45
|
+
1<>コンテンツ1
|
46
|
+
|
47
|
+
2<>コンテンツ2
|
48
|
+
|
49
|
+
3<>コンテンツ3
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
> 出力
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
1<>コンテンツ1
|
60
|
+
|
61
|
+
4<>コンテンツ差し替え
|
62
|
+
|
63
|
+
3<>コンテンツ3
|
64
|
+
|
65
|
+
```
|