teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2016/11/29 17:13

投稿

退会済みユーザー
answer CHANGED
@@ -20,4 +20,18 @@
20
20
  preg_match_all("/(\/\w+\d)/", $path, $matches);
21
21
  var_dump($matches[0]);
22
22
 
23
+ ```
24
+
25
+ ---
26
+
27
+ ```php
28
+ <?php
29
+
30
+ $url1 = "http://samples.com/hoge/param1/param2/param3/param4/paramN";
31
+ $pu = parse_url($url1);
32
+ $path = $pu['path'];
33
+
34
+ preg_match_all("/(\/(\w+\d))/", $path, $matches);
35
+ var_dump($matches[2]);
36
+
23
37
  ```

1

追記

2016/11/29 17:13

投稿

退会済みユーザー
answer CHANGED
@@ -6,4 +6,18 @@
6
6
  $res1 = parse_url($url1);
7
7
  $arr = explode('/', $res1['path']);
8
8
  var_dump($arr);
9
+ ```
10
+
11
+ ---
12
+
13
+ ```php
14
+ <?php
15
+
16
+ $url1 = "http://samples.com/hoge/param1/param2/param3/param4/paramN";
17
+ $pu = parse_url($url1);
18
+ $path = $pu['path'];
19
+
20
+ preg_match_all("/(\/\w+\d)/", $path, $matches);
21
+ var_dump($matches[0]);
22
+
9
23
  ```