回答編集履歴

1

1

2016/08/07 08:12

投稿

takasima20
takasima20

スコア7458

test CHANGED
@@ -21,3 +21,55 @@
21
21
  $url = 'http://' . array_pop($eq) . '.com/';
22
22
 
23
23
  ```
24
+
25
+ --- 追加 ---
26
+
27
+
28
+
29
+ そういうときは
30
+
31
+ ```PHP
32
+
33
+ $a = '2,4,5'
34
+
35
+ $b = '1,3,4'
36
+
37
+
38
+
39
+ $pref_data = array(
40
+
41
+ '北海道' => array($a,'hokkaidou'),
42
+
43
+ '東京' => array($b,'toukyou'));
44
+
45
+ list($s1, $s2) = $pref_data[$switch];
46
+
47
+ $eq = explode(',', $s1);
48
+
49
+ $url = 'http://' . $s2 . '.com/';
50
+
51
+ ```
52
+
53
+ もしくは
54
+
55
+ ```PHP
56
+
57
+ $a = array(2,4,5);
58
+
59
+ $b = array(1,3,4);
60
+
61
+
62
+
63
+ $pref_data = array(
64
+
65
+ '北海道' => array($a,'hokkaidou'),
66
+
67
+ '東京' => array($b,'toukyou'));
68
+
69
+ list($eq, $str) = $pref_data[$switch];
70
+
71
+ $url = 'http://' . $str . '.com/';
72
+
73
+ ```
74
+
75
+