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

質問編集履歴

3

「```<?」では<?が表示消えてしまうため、間に改行追加

2018/03/29 16:17

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -31,7 +31,9 @@
31
31
 
32
32
  ### index.phpファイル
33
33
  こういうこと?と書いてみた失敗コード
34
+ ```
34
- ```<?
35
+ <?
36
+
35
37
  php foreach ($a_data as $row) {
36
38
 
37
39
  php echo $row['a_data'];

2

ご指摘ありがとうございました。コードを自分なりに見やすくなるよう記載しなおしてみました。よろしくお願いいします。

2018/03/29 16:17

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -12,30 +12,31 @@
12
12
 
13
13
  ### Logicファイル内関係コード
14
14
 
15
+
16
+ ```
15
17
  $view_data['a_data'] = (DB接続)->select_all('category', array('parent_category_code' => $category_a_code, 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
16
-
17
18
  foreach($view_data['a_data'] as $k => &$category_b) {
18
-
19
- $category_b['category_c'] = (DB接続) ->select_all('category', array('parent_category_code' => $category_b['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
19
+ $category_b['category_c'] = (DB接続) ->select_all('category', array('parent_category_code' => $category_b['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
20
- foreach($category_b['category_c'] as $k => &$category_c) {
20
+ foreach($category_b['category_c'] as $k => &$category_c) {
21
-
22
- $help = (DB接続) ->select_all('help', array('category_c' => $category_c['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
21
+ $help = (DB接続) ->select_all('help', array('category_c' => $category_c['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
23
- $category_c['help'] = empty($help) ? array() : $help;
22
+ $category_c['help'] = empty($help) ? array() : $help;
23
+ }
24
+ unset($category_c);
24
25
  }
25
- unset($category_c);
26
- }
27
26
  unset($category_b);
28
27
 
29
28
  return $view_data;
29
+
30
- }
30
+ ```
31
+
31
32
  ### index.phpファイル
32
33
  こういうこと?と書いてみた失敗コード
33
-
34
- <?
34
+ ```<?
35
35
  php foreach ($a_data as $row) {
36
36
 
37
37
  php echo $row['a_data'];
38
38
  php echo $row['category_b'];
39
39
  php echo $row['category_c'];
40
40
 
41
- ?>
41
+ ?>
42
+ ```

1

2018/03/29 16:15

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -13,22 +13,29 @@
13
13
  ### Logicファイル内関係コード
14
14
 
15
15
  $view_data['a_data'] = (DB接続)->select_all('category', array('parent_category_code' => $category_a_code, 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
16
+
16
- foreach($view_data['a_data'] as $k => &$category_b) {
17
+ foreach($view_data['a_data'] as $k => &$category_b) {
18
+
17
- $category_b['category_c'] = DB接続->select_all('category', array('parent_category_code' => $category_b['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
19
+ $category_b['category_c'] = (DB接続) ->select_all('category', array('parent_category_code' => $category_b['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
18
20
  foreach($category_b['category_c'] as $k => &$category_c) {
21
+
19
- $help = DB接続->select_all('help', array('category_c' => $category_c['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
22
+ $help = (DB接続) ->select_all('help', array('category_c' => $category_c['category_code'], 'delete_flg' => FLG_FALSE), array('disp_order' => 'ASC'));
20
23
  $category_c['help'] = empty($help) ? array() : $help;
21
- }
24
+ }
22
- unset($category_c);
25
+ unset($category_c);
23
- }
26
+ }
24
- unset($category_b);
27
+ unset($category_b);
25
28
 
26
- return $view_data;
29
+ return $view_data;
27
- }
30
+ }
28
31
  ### index.phpファイル
29
32
  こういうこと?と書いてみた失敗コード
30
33
 
34
+ <?
31
- <?php foreach ($a_data as $row) { ?>
35
+ php foreach ($a_data as $row) {
36
+
32
- <?php echo $row['a_data']; ?>
37
+ php echo $row['a_data'];
33
- <?php echo $row['category_b']; ?>
38
+ php echo $row['category_b'];
34
- <?php echo $row['category_c']; ?>
39
+ php echo $row['category_c'];
40
+
41
+ ?>