作者:呵呵 | 来源:互联网 | 2023-08-15 01:37
Imtryingtobuildatableofresultsfromanarray.Icurrentlyhaveresultsoutputtinglikethis:
I'm trying to build a table of results from an array. I currently have results outputting like this:
我正在尝试从数组中构建一个结果表。我目前的结果输出如下:
ID VALUE EXTRA
--------------------------------------
| 1 | Value 1 | Extra 1 |
|-----|---------------------|----------|
| 1 | Value 2 | Extra 2 |
|-----|---------------------|----------|
| 2 | Value 3 | Some 1 |
|-----|---------------------|----------|
| 3 | Value 4 | Some 2 |
|-----|---------------------|----------|
| 3 | Value 5 | Nothing |
--------------------------------------
Note the repeating ID value. What I'd like to do is build a loop inside my current loop that will not display duplicate IDs. Something like this:
请注意重复的ID值。我想要做的是在我当前的循环中构建一个循环,它不会显示重复的ID。像这样的东西:
ID VALUE EXTRA
--------------------------------------
| 1 | Value 1 | Extra 1 |
| |---------------------|----------|
| | Value 2 | Extra 2 |
|-----|---------------------|----------|
| 2 | Value 3 | Some 1 |
|-----|---------------------|----------|
| 3 | Value 4 | Some 2 |
| |---------------------|----------|
| | Value 5 | Nothing |
--------------------------------------
Here's my current code, simplified:
这是我当前的代码,简化:
|
|
|
Is there a way to build this table dynamically in the way I want? Or should I rethink my strategy?
有没有办法以我想要的方式动态构建这个表?或者我应该重新考虑我的策略?
2 个解决方案