回答編集履歴

2

a

2016/04/07 21:49

投稿

mpyw
mpyw

スコア5223

test CHANGED
@@ -20,9 +20,11 @@
20
20
 
21
21
  ```php
22
22
 
23
+ $haystack = file_get_contents('haystack.txt');
24
+
23
25
  $needle = 'http://example.com/example.html';
24
26
 
25
- if (strpos(file_get_contents('haystack.txt'), $needle) !== false) {
27
+ if (strpos($haystack, $needle) !== false) {
26
28
 
27
29
  echo '見つかりました';
28
30
 

1

a

2016/04/07 21:49

投稿

mpyw
mpyw

スコア5223

test CHANGED
@@ -15,3 +15,21 @@
15
15
 
16
16
 
17
17
  - [strpos](http://php.net/manual/ja/function.strpos.php)
18
+
19
+
20
+
21
+ ```php
22
+
23
+ $needle = 'http://example.com/example.html';
24
+
25
+ if (strpos(file_get_contents('haystack.txt'), $needle) !== false) {
26
+
27
+ echo '見つかりました';
28
+
29
+ } else {
30
+
31
+ echo '見つかりませんでした';
32
+
33
+ }
34
+
35
+ ```