質問編集履歴

2

内容の変更

2016/06/13 03:45

投稿

Chelsea_10
Chelsea_10

スコア46

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  //ドメイン
8
8
 
9
- $domainList = array("sample.jp","sample.com","sample.co.jp");
9
+ $domainList = array("sample.jp","sample.co.jp",sample.com");
10
10
 
11
11
 
12
12
 
@@ -102,9 +102,9 @@
102
102
 
103
103
  //理想
104
104
 
105
- $getInfo['url'] =array("http://sample.jp/aaa.html","http://sample.com/aaa.html","該当なし");
105
+ $getInfo['url'] =array("http://sample.jp/aaa.html","該当なし","http://sample.com/aaa.html");
106
106
 
107
- $getInfo['title'] =array("sample.jpのサイトタイトル1","sample.comのサイトタイトル1","該当なし");
107
+ $getInfo['title'] =array("sample.jpのサイトタイトル1","該当なし",sample.comのサイトタイトル1");
108
108
 
109
109
  ```
110
110
 

1

コードの更新

2016/06/13 03:45

投稿

Chelsea_10
Chelsea_10

スコア46

test CHANGED
File without changes
test CHANGED
@@ -28,19 +28,7 @@
28
28
 
29
29
  これを一番初めに検知されたもののみ
30
30
 
31
- URLでカンマ区切りされているURLとサイトタイトルを連想配列にして格納したいのですがどのようにすればよろしいでしょうか?
31
+ URLでカンマ区切りされているURLとサイトタイトルを連想配列(一致しないドメインしては該当なし)にして格納したいのですがどのようにすればよろしいでしょうか?
32
-
33
-
34
-
35
- ```php
36
-
37
- //理想
38
-
39
- $getInfo['url'] =array("http://sample.jp/aaa.html","http://sample.com/aaa.html");
40
-
41
- $getInfo['title'] =array("sample.jpのサイトタイトル1","sample.comのサイトタイトル1");
42
-
43
- ```
44
32
 
45
33
 
46
34
 
@@ -64,15 +52,19 @@
64
52
 
65
53
  $explodeUrlList = explode( ',', $url);
66
54
 
67
- var_dump($explodeUrlList);
68
-
69
55
  $getInfo['url'] = $explodeUrlList[0];
70
56
 
71
57
  $getInfo['title'] = $explodeUrlList[1];
72
58
 
73
-
59
+ break;
74
60
 
61
+ } else {
62
+
63
+ $getInfo['url'] = "該当なし";
64
+
65
+ $getInfo['title'] = "該当なし";
66
+
75
- }
67
+ }
76
68
 
77
69
  }
78
70
 
@@ -94,7 +86,7 @@
94
86
 
95
87
  var_dump($getInfo);
96
88
 
97
- array(2) { ["url"]=> string(19) "sample.com/bbb.html" ["title"]=> string(35) "sample.comのサイトタイトル2" }
89
+ array(2) { ["url"]=> string(12) "該当なし" ["title"]=> string(12) "該当なし" } array(2) { ["url"]=> string(12) "該当なし" ["title"]=> string(12) "該当なし" }
98
90
 
99
91
  ```
100
92