回答編集履歴
3
修正
test
CHANGED
@@ -14,11 +14,13 @@
|
|
14
14
|
|
15
15
|
// 中略
|
16
16
|
|
17
|
-
$ancestor = get_ancestors($cat_id, 'category');
|
17
|
+
$ancestor = get_ancestors($cat_id, 'category');
|
18
18
|
|
19
|
-
$ancestor = array_pop($ancestor);
|
19
|
+
$ancestor = array_pop($ancestor);
|
20
20
|
|
21
21
|
$categories[] = $ancestor;
|
22
|
+
|
23
|
+
|
22
24
|
|
23
25
|
//ループ終了後に
|
24
26
|
|
2
修正
test
CHANGED
@@ -6,11 +6,23 @@
|
|
6
6
|
|
7
7
|
```php
|
8
8
|
|
9
|
+
//ループ外で
|
10
|
+
|
11
|
+
$categories = [];
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
// 中略
|
16
|
+
|
9
17
|
$ancestor = get_ancestors($cat_id, 'category');
|
18
|
+
|
19
|
+
$ancestor = array_pop($ancestor);
|
20
|
+
|
21
|
+
$categories[] = $ancestor;
|
10
22
|
|
11
23
|
//ループ終了後に
|
12
24
|
|
13
|
-
return $a
|
25
|
+
return $categories;
|
14
26
|
|
15
27
|
|
16
28
|
|
1
修正
test
CHANGED
@@ -2,25 +2,15 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
### 変更
|
6
|
+
|
5
7
|
```php
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
$categories = [];
|
10
|
-
|
11
|
-
|
12
8
|
|
13
9
|
$ancestor = get_ancestors($cat_id, 'category');
|
14
10
|
|
15
|
-
$ancestor = array_pop($ancestor);
|
16
|
-
|
17
|
-
$categories[] = $ancestor;
|
18
|
-
|
19
|
-
|
20
|
-
|
21
11
|
//ループ終了後に
|
22
12
|
|
23
|
-
return $c
|
13
|
+
return $ancestor;
|
24
14
|
|
25
15
|
|
26
16
|
|