質問編集履歴
2
質問文を修正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -139,393 +139,3 @@
|
|
139
139
|
|
140
140
|
|
141
141
|
```
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
### 追記
|
146
|
-
|
147
|
-
回答いただきました方法と[こちら](https://qiita.com/yorozuone/items/736a3cda7264046d6f3e)を参考に実行しましたら下記のように表示されました。
|
148
|
-
|
149
|
-
コメントアウトを外した場合構文エラーとなります。
|
150
|
-
|
151
|
-
最初に示しましたツリーのようにするにはどう出力したらよろしいのでしょうか?
|
152
|
-
|
153
|
-
```ここに言語を入力
|
154
|
-
|
155
|
-
Array
|
156
|
-
|
157
|
-
(
|
158
|
-
|
159
|
-
[0] => Array
|
160
|
-
|
161
|
-
(
|
162
|
-
|
163
|
-
[id] => 1418
|
164
|
-
|
165
|
-
[0] => 1419
|
166
|
-
|
167
|
-
[name] => アメリカ
|
168
|
-
|
169
|
-
[1] => アラスカ
|
170
|
-
|
171
|
-
[subject] => トランプ.1
|
172
|
-
|
173
|
-
[2] => マイク
|
174
|
-
|
175
|
-
[body] => Thanks
|
176
|
-
|
177
|
-
[3] => Thanks
|
178
|
-
|
179
|
-
[parent_id] =>
|
180
|
-
|
181
|
-
[4] => 1418
|
182
|
-
|
183
|
-
[post_user] =>
|
184
|
-
|
185
|
-
[5] =>
|
186
|
-
|
187
|
-
[created_at] => 2020-03-17 13:42:24
|
188
|
-
|
189
|
-
[6] => 2020-03-17 13:42:24
|
190
|
-
|
191
|
-
[updated_at] => 2020-03-26 10:28:31
|
192
|
-
|
193
|
-
[7] => 2020-03-18 14:28:50
|
194
|
-
|
195
|
-
[deleted_at] => 2020-03-26 10:28:31
|
196
|
-
|
197
|
-
[8] =>
|
198
|
-
|
199
|
-
[9] => 1418
|
200
|
-
|
201
|
-
[10] => アメリカ
|
202
|
-
|
203
|
-
[11] => トランプ.1
|
204
|
-
|
205
|
-
[12] => Thanks
|
206
|
-
|
207
|
-
[13] =>
|
208
|
-
|
209
|
-
[14] =>
|
210
|
-
|
211
|
-
[15] => 2020-03-17 13:42:24
|
212
|
-
|
213
|
-
[16] => 2020-03-26 10:28:31
|
214
|
-
|
215
|
-
[17] => 2020-03-26 10:28:31
|
216
|
-
|
217
|
-
)
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
[1] => Array
|
222
|
-
|
223
|
-
(
|
224
|
-
|
225
|
-
[id] => 1418
|
226
|
-
|
227
|
-
[0] => 1420
|
228
|
-
|
229
|
-
[name] => アメリカ
|
230
|
-
|
231
|
-
[1] => アリゾナ
|
232
|
-
|
233
|
-
[subject] => トランプ.1
|
234
|
-
|
235
|
-
[2] => ダグ
|
236
|
-
|
237
|
-
[body] => Thanks
|
238
|
-
|
239
|
-
[3] => Thanks
|
240
|
-
|
241
|
-
[parent_id] =>
|
242
|
-
|
243
|
-
[4] => 1418
|
244
|
-
|
245
|
-
[post_user] =>
|
246
|
-
|
247
|
-
[5] =>
|
248
|
-
|
249
|
-
[created_at] => 2020-03-17 13:42:24
|
250
|
-
|
251
|
-
[6] => 2020-03-17 13:42:24
|
252
|
-
|
253
|
-
[updated_at] => 2020-03-26 10:28:31
|
254
|
-
|
255
|
-
[7] => 2020-03-18 14:28:50
|
256
|
-
|
257
|
-
[deleted_at] => 2020-03-26 10:28:31
|
258
|
-
|
259
|
-
[8] =>
|
260
|
-
|
261
|
-
[9] => 1418
|
262
|
-
|
263
|
-
[10] => アメリカ
|
264
|
-
|
265
|
-
[11] => トランプ.1
|
266
|
-
|
267
|
-
[12] => Thanks
|
268
|
-
|
269
|
-
[13] =>
|
270
|
-
|
271
|
-
[14] =>
|
272
|
-
|
273
|
-
[15] => 2020-03-17 13:42:24
|
274
|
-
|
275
|
-
[16] => 2020-03-26 10:28:31
|
276
|
-
|
277
|
-
[17] => 2020-03-26 10:28:31
|
278
|
-
|
279
|
-
)
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
[2] => Array
|
284
|
-
|
285
|
-
(
|
286
|
-
|
287
|
-
[id] => 1418
|
288
|
-
|
289
|
-
[0] => 1421
|
290
|
-
|
291
|
-
[name] => アメリカ
|
292
|
-
|
293
|
-
[1] => カリフォルニア
|
294
|
-
|
295
|
-
[subject] => トランプ.1
|
296
|
-
|
297
|
-
[2] => キャビン
|
298
|
-
|
299
|
-
[body] => Thanks
|
300
|
-
|
301
|
-
[3] => Thanks
|
302
|
-
|
303
|
-
[parent_id] =>
|
304
|
-
|
305
|
-
[4] => 1418
|
306
|
-
|
307
|
-
[post_user] =>
|
308
|
-
|
309
|
-
[5] =>
|
310
|
-
|
311
|
-
[created_at] => 2020-03-17 13:42:24
|
312
|
-
|
313
|
-
[6] => 2020-03-17 13:42:24
|
314
|
-
|
315
|
-
[updated_at] => 2020-03-26 10:28:31
|
316
|
-
|
317
|
-
[7] => 2020-03-18 14:28:50
|
318
|
-
|
319
|
-
[deleted_at] => 2020-03-26 10:28:31
|
320
|
-
|
321
|
-
[8] =>
|
322
|
-
|
323
|
-
[9] => 1418
|
324
|
-
|
325
|
-
[10] => アメリカ
|
326
|
-
|
327
|
-
[11] => トランプ.1
|
328
|
-
|
329
|
-
[12] => Thanks
|
330
|
-
|
331
|
-
[13] =>
|
332
|
-
|
333
|
-
[14] =>
|
334
|
-
|
335
|
-
[15] => 2020-03-17 13:42:24
|
336
|
-
|
337
|
-
[16] => 2020-03-26 10:28:31
|
338
|
-
|
339
|
-
[17] => 2020-03-26 10:28:31
|
340
|
-
|
341
|
-
)
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
[3] => Array
|
346
|
-
|
347
|
-
(
|
348
|
-
|
349
|
-
[id] => 1418
|
350
|
-
|
351
|
-
[0] => 1422
|
352
|
-
|
353
|
-
[name] => アメリカ
|
354
|
-
|
355
|
-
[1] => コロラド
|
356
|
-
|
357
|
-
[subject] => トランプ.1
|
358
|
-
|
359
|
-
[2] => ジャレド
|
360
|
-
|
361
|
-
[body] => Thanks
|
362
|
-
|
363
|
-
[3] => Thanks
|
364
|
-
|
365
|
-
[parent_id] =>
|
366
|
-
|
367
|
-
[4] => 1418
|
368
|
-
|
369
|
-
[post_user] =>
|
370
|
-
|
371
|
-
[5] =>
|
372
|
-
|
373
|
-
[created_at] => 2020-03-17 13:42:24
|
374
|
-
|
375
|
-
[6] => 2020-03-17 13:42:24
|
376
|
-
|
377
|
-
[updated_at] => 2020-03-26 10:28:31
|
378
|
-
|
379
|
-
[7] => 2020-03-18 14:28:50
|
380
|
-
|
381
|
-
[deleted_at] => 2020-03-26 10:28:31
|
382
|
-
|
383
|
-
[8] =>
|
384
|
-
|
385
|
-
[9] => 1418
|
386
|
-
|
387
|
-
[10] => アメリカ
|
388
|
-
|
389
|
-
[11] => トランプ.1
|
390
|
-
|
391
|
-
[12] => Thanks
|
392
|
-
|
393
|
-
[13] =>
|
394
|
-
|
395
|
-
[14] =>
|
396
|
-
|
397
|
-
[15] => 2020-03-17 13:42:24
|
398
|
-
|
399
|
-
[16] => 2020-03-26 10:28:31
|
400
|
-
|
401
|
-
[17] => 2020-03-26 10:28:31
|
402
|
-
|
403
|
-
)
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
[4] => Array
|
408
|
-
|
409
|
-
(
|
410
|
-
|
411
|
-
[id] => 1418
|
412
|
-
|
413
|
-
[0] => 1423
|
414
|
-
|
415
|
-
[name] => アメリカ
|
416
|
-
|
417
|
-
[1] => フロリダ
|
418
|
-
|
419
|
-
[subject] => トランプ.1
|
420
|
-
|
421
|
-
[2] => ロン
|
422
|
-
|
423
|
-
[body] => Thanks
|
424
|
-
|
425
|
-
[3] => Thanks
|
426
|
-
|
427
|
-
[parent_id] =>
|
428
|
-
|
429
|
-
[4] => 1418
|
430
|
-
|
431
|
-
[post_user] =>
|
432
|
-
|
433
|
-
[5] =>
|
434
|
-
|
435
|
-
[created_at] => 2020-03-17 13:42:24
|
436
|
-
|
437
|
-
[6] => 2020-03-17 13:42:24
|
438
|
-
|
439
|
-
[updated_at] => 2020-03-26 10:28:31
|
440
|
-
|
441
|
-
[7] => 2020-03-18 14:28:50
|
442
|
-
|
443
|
-
[deleted_at] => 2020-03-26 10:28:31
|
444
|
-
|
445
|
-
[8] =>
|
446
|
-
|
447
|
-
[9] => 1418
|
448
|
-
|
449
|
-
[10] => アメリカ
|
450
|
-
|
451
|
-
[11] => トランプ.1
|
452
|
-
|
453
|
-
[12] => Thanks
|
454
|
-
|
455
|
-
[13] =>
|
456
|
-
|
457
|
-
[14] =>
|
458
|
-
|
459
|
-
[15] => 2020-03-17 13:42:24
|
460
|
-
|
461
|
-
[16] => 2020-03-26 10:28:31
|
462
|
-
|
463
|
-
[17] => 2020-03-26 10:28:31
|
464
|
-
|
465
|
-
)
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
```
|
470
|
-
|
471
|
-
```php
|
472
|
-
|
473
|
-
$stmt=$db->prepare("select * from t_bbs as t1 left join t_bbs as t2 on t1.parent_id = t2.id where t2.deleted_at is not null order by t2.id desc;");
|
474
|
-
|
475
|
-
$stmt->execute();
|
476
|
-
|
477
|
-
$row = $stmt->fetchAll();
|
478
|
-
|
479
|
-
// foreach($rows as $row){
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
// }
|
484
|
-
|
485
|
-
// 再帰で関数を呼び出します。
|
486
|
-
|
487
|
-
// RecursionArray($row, 0, $rows, 0);
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
// 実行結果表示
|
492
|
-
|
493
|
-
echo('<pre>');
|
494
|
-
|
495
|
-
print_r($row);
|
496
|
-
|
497
|
-
echo('</pre>');
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
// 再帰処理用の関数です。
|
502
|
-
|
503
|
-
// function RecursionArray($row, $ParentId, &$rows, $hierarchy) {
|
504
|
-
|
505
|
-
//
|
506
|
-
|
507
|
-
// foreach($row as $v) {
|
508
|
-
|
509
|
-
// if ($v['ParentId'] == $ParentId) {
|
510
|
-
|
511
|
-
// $rows[] = row_repeat('-', $hierarchy).$v['name'];
|
512
|
-
|
513
|
-
// RecursionArray($row, $v['Id'], $rows, $hierarchy+1);
|
514
|
-
|
515
|
-
// }
|
516
|
-
|
517
|
-
// }
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
// }
|
522
|
-
|
523
|
-
// while ($rows = $stmt->fetchAll()) {
|
524
|
-
|
525
|
-
// $rows[] = $row;
|
526
|
-
|
527
|
-
// var_dump($rows);
|
528
|
-
|
529
|
-
// }
|
530
|
-
|
531
|
-
```
|
1
追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -139,3 +139,393 @@
|
|
139
139
|
|
140
140
|
|
141
141
|
```
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
### 追記
|
146
|
+
|
147
|
+
回答いただきました方法と[こちら](https://qiita.com/yorozuone/items/736a3cda7264046d6f3e)を参考に実行しましたら下記のように表示されました。
|
148
|
+
|
149
|
+
コメントアウトを外した場合構文エラーとなります。
|
150
|
+
|
151
|
+
最初に示しましたツリーのようにするにはどう出力したらよろしいのでしょうか?
|
152
|
+
|
153
|
+
```ここに言語を入力
|
154
|
+
|
155
|
+
Array
|
156
|
+
|
157
|
+
(
|
158
|
+
|
159
|
+
[0] => Array
|
160
|
+
|
161
|
+
(
|
162
|
+
|
163
|
+
[id] => 1418
|
164
|
+
|
165
|
+
[0] => 1419
|
166
|
+
|
167
|
+
[name] => アメリカ
|
168
|
+
|
169
|
+
[1] => アラスカ
|
170
|
+
|
171
|
+
[subject] => トランプ.1
|
172
|
+
|
173
|
+
[2] => マイク
|
174
|
+
|
175
|
+
[body] => Thanks
|
176
|
+
|
177
|
+
[3] => Thanks
|
178
|
+
|
179
|
+
[parent_id] =>
|
180
|
+
|
181
|
+
[4] => 1418
|
182
|
+
|
183
|
+
[post_user] =>
|
184
|
+
|
185
|
+
[5] =>
|
186
|
+
|
187
|
+
[created_at] => 2020-03-17 13:42:24
|
188
|
+
|
189
|
+
[6] => 2020-03-17 13:42:24
|
190
|
+
|
191
|
+
[updated_at] => 2020-03-26 10:28:31
|
192
|
+
|
193
|
+
[7] => 2020-03-18 14:28:50
|
194
|
+
|
195
|
+
[deleted_at] => 2020-03-26 10:28:31
|
196
|
+
|
197
|
+
[8] =>
|
198
|
+
|
199
|
+
[9] => 1418
|
200
|
+
|
201
|
+
[10] => アメリカ
|
202
|
+
|
203
|
+
[11] => トランプ.1
|
204
|
+
|
205
|
+
[12] => Thanks
|
206
|
+
|
207
|
+
[13] =>
|
208
|
+
|
209
|
+
[14] =>
|
210
|
+
|
211
|
+
[15] => 2020-03-17 13:42:24
|
212
|
+
|
213
|
+
[16] => 2020-03-26 10:28:31
|
214
|
+
|
215
|
+
[17] => 2020-03-26 10:28:31
|
216
|
+
|
217
|
+
)
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
[1] => Array
|
222
|
+
|
223
|
+
(
|
224
|
+
|
225
|
+
[id] => 1418
|
226
|
+
|
227
|
+
[0] => 1420
|
228
|
+
|
229
|
+
[name] => アメリカ
|
230
|
+
|
231
|
+
[1] => アリゾナ
|
232
|
+
|
233
|
+
[subject] => トランプ.1
|
234
|
+
|
235
|
+
[2] => ダグ
|
236
|
+
|
237
|
+
[body] => Thanks
|
238
|
+
|
239
|
+
[3] => Thanks
|
240
|
+
|
241
|
+
[parent_id] =>
|
242
|
+
|
243
|
+
[4] => 1418
|
244
|
+
|
245
|
+
[post_user] =>
|
246
|
+
|
247
|
+
[5] =>
|
248
|
+
|
249
|
+
[created_at] => 2020-03-17 13:42:24
|
250
|
+
|
251
|
+
[6] => 2020-03-17 13:42:24
|
252
|
+
|
253
|
+
[updated_at] => 2020-03-26 10:28:31
|
254
|
+
|
255
|
+
[7] => 2020-03-18 14:28:50
|
256
|
+
|
257
|
+
[deleted_at] => 2020-03-26 10:28:31
|
258
|
+
|
259
|
+
[8] =>
|
260
|
+
|
261
|
+
[9] => 1418
|
262
|
+
|
263
|
+
[10] => アメリカ
|
264
|
+
|
265
|
+
[11] => トランプ.1
|
266
|
+
|
267
|
+
[12] => Thanks
|
268
|
+
|
269
|
+
[13] =>
|
270
|
+
|
271
|
+
[14] =>
|
272
|
+
|
273
|
+
[15] => 2020-03-17 13:42:24
|
274
|
+
|
275
|
+
[16] => 2020-03-26 10:28:31
|
276
|
+
|
277
|
+
[17] => 2020-03-26 10:28:31
|
278
|
+
|
279
|
+
)
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
[2] => Array
|
284
|
+
|
285
|
+
(
|
286
|
+
|
287
|
+
[id] => 1418
|
288
|
+
|
289
|
+
[0] => 1421
|
290
|
+
|
291
|
+
[name] => アメリカ
|
292
|
+
|
293
|
+
[1] => カリフォルニア
|
294
|
+
|
295
|
+
[subject] => トランプ.1
|
296
|
+
|
297
|
+
[2] => キャビン
|
298
|
+
|
299
|
+
[body] => Thanks
|
300
|
+
|
301
|
+
[3] => Thanks
|
302
|
+
|
303
|
+
[parent_id] =>
|
304
|
+
|
305
|
+
[4] => 1418
|
306
|
+
|
307
|
+
[post_user] =>
|
308
|
+
|
309
|
+
[5] =>
|
310
|
+
|
311
|
+
[created_at] => 2020-03-17 13:42:24
|
312
|
+
|
313
|
+
[6] => 2020-03-17 13:42:24
|
314
|
+
|
315
|
+
[updated_at] => 2020-03-26 10:28:31
|
316
|
+
|
317
|
+
[7] => 2020-03-18 14:28:50
|
318
|
+
|
319
|
+
[deleted_at] => 2020-03-26 10:28:31
|
320
|
+
|
321
|
+
[8] =>
|
322
|
+
|
323
|
+
[9] => 1418
|
324
|
+
|
325
|
+
[10] => アメリカ
|
326
|
+
|
327
|
+
[11] => トランプ.1
|
328
|
+
|
329
|
+
[12] => Thanks
|
330
|
+
|
331
|
+
[13] =>
|
332
|
+
|
333
|
+
[14] =>
|
334
|
+
|
335
|
+
[15] => 2020-03-17 13:42:24
|
336
|
+
|
337
|
+
[16] => 2020-03-26 10:28:31
|
338
|
+
|
339
|
+
[17] => 2020-03-26 10:28:31
|
340
|
+
|
341
|
+
)
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
[3] => Array
|
346
|
+
|
347
|
+
(
|
348
|
+
|
349
|
+
[id] => 1418
|
350
|
+
|
351
|
+
[0] => 1422
|
352
|
+
|
353
|
+
[name] => アメリカ
|
354
|
+
|
355
|
+
[1] => コロラド
|
356
|
+
|
357
|
+
[subject] => トランプ.1
|
358
|
+
|
359
|
+
[2] => ジャレド
|
360
|
+
|
361
|
+
[body] => Thanks
|
362
|
+
|
363
|
+
[3] => Thanks
|
364
|
+
|
365
|
+
[parent_id] =>
|
366
|
+
|
367
|
+
[4] => 1418
|
368
|
+
|
369
|
+
[post_user] =>
|
370
|
+
|
371
|
+
[5] =>
|
372
|
+
|
373
|
+
[created_at] => 2020-03-17 13:42:24
|
374
|
+
|
375
|
+
[6] => 2020-03-17 13:42:24
|
376
|
+
|
377
|
+
[updated_at] => 2020-03-26 10:28:31
|
378
|
+
|
379
|
+
[7] => 2020-03-18 14:28:50
|
380
|
+
|
381
|
+
[deleted_at] => 2020-03-26 10:28:31
|
382
|
+
|
383
|
+
[8] =>
|
384
|
+
|
385
|
+
[9] => 1418
|
386
|
+
|
387
|
+
[10] => アメリカ
|
388
|
+
|
389
|
+
[11] => トランプ.1
|
390
|
+
|
391
|
+
[12] => Thanks
|
392
|
+
|
393
|
+
[13] =>
|
394
|
+
|
395
|
+
[14] =>
|
396
|
+
|
397
|
+
[15] => 2020-03-17 13:42:24
|
398
|
+
|
399
|
+
[16] => 2020-03-26 10:28:31
|
400
|
+
|
401
|
+
[17] => 2020-03-26 10:28:31
|
402
|
+
|
403
|
+
)
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
[4] => Array
|
408
|
+
|
409
|
+
(
|
410
|
+
|
411
|
+
[id] => 1418
|
412
|
+
|
413
|
+
[0] => 1423
|
414
|
+
|
415
|
+
[name] => アメリカ
|
416
|
+
|
417
|
+
[1] => フロリダ
|
418
|
+
|
419
|
+
[subject] => トランプ.1
|
420
|
+
|
421
|
+
[2] => ロン
|
422
|
+
|
423
|
+
[body] => Thanks
|
424
|
+
|
425
|
+
[3] => Thanks
|
426
|
+
|
427
|
+
[parent_id] =>
|
428
|
+
|
429
|
+
[4] => 1418
|
430
|
+
|
431
|
+
[post_user] =>
|
432
|
+
|
433
|
+
[5] =>
|
434
|
+
|
435
|
+
[created_at] => 2020-03-17 13:42:24
|
436
|
+
|
437
|
+
[6] => 2020-03-17 13:42:24
|
438
|
+
|
439
|
+
[updated_at] => 2020-03-26 10:28:31
|
440
|
+
|
441
|
+
[7] => 2020-03-18 14:28:50
|
442
|
+
|
443
|
+
[deleted_at] => 2020-03-26 10:28:31
|
444
|
+
|
445
|
+
[8] =>
|
446
|
+
|
447
|
+
[9] => 1418
|
448
|
+
|
449
|
+
[10] => アメリカ
|
450
|
+
|
451
|
+
[11] => トランプ.1
|
452
|
+
|
453
|
+
[12] => Thanks
|
454
|
+
|
455
|
+
[13] =>
|
456
|
+
|
457
|
+
[14] =>
|
458
|
+
|
459
|
+
[15] => 2020-03-17 13:42:24
|
460
|
+
|
461
|
+
[16] => 2020-03-26 10:28:31
|
462
|
+
|
463
|
+
[17] => 2020-03-26 10:28:31
|
464
|
+
|
465
|
+
)
|
466
|
+
|
467
|
+
|
468
|
+
|
469
|
+
```
|
470
|
+
|
471
|
+
```php
|
472
|
+
|
473
|
+
$stmt=$db->prepare("select * from t_bbs as t1 left join t_bbs as t2 on t1.parent_id = t2.id where t2.deleted_at is not null order by t2.id desc;");
|
474
|
+
|
475
|
+
$stmt->execute();
|
476
|
+
|
477
|
+
$row = $stmt->fetchAll();
|
478
|
+
|
479
|
+
// foreach($rows as $row){
|
480
|
+
|
481
|
+
|
482
|
+
|
483
|
+
// }
|
484
|
+
|
485
|
+
// 再帰で関数を呼び出します。
|
486
|
+
|
487
|
+
// RecursionArray($row, 0, $rows, 0);
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
// 実行結果表示
|
492
|
+
|
493
|
+
echo('<pre>');
|
494
|
+
|
495
|
+
print_r($row);
|
496
|
+
|
497
|
+
echo('</pre>');
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
// 再帰処理用の関数です。
|
502
|
+
|
503
|
+
// function RecursionArray($row, $ParentId, &$rows, $hierarchy) {
|
504
|
+
|
505
|
+
//
|
506
|
+
|
507
|
+
// foreach($row as $v) {
|
508
|
+
|
509
|
+
// if ($v['ParentId'] == $ParentId) {
|
510
|
+
|
511
|
+
// $rows[] = row_repeat('-', $hierarchy).$v['name'];
|
512
|
+
|
513
|
+
// RecursionArray($row, $v['Id'], $rows, $hierarchy+1);
|
514
|
+
|
515
|
+
// }
|
516
|
+
|
517
|
+
// }
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
// }
|
522
|
+
|
523
|
+
// while ($rows = $stmt->fetchAll()) {
|
524
|
+
|
525
|
+
// $rows[] = $row;
|
526
|
+
|
527
|
+
// var_dump($rows);
|
528
|
+
|
529
|
+
// }
|
530
|
+
|
531
|
+
```
|