admin管理员组文章数量:1430077
This is pretty abstract and isn't truly WordPress related, except that I'm storing this data in a WordPress installation, so I am limited to PHP/MySQL-esque parameters.
Here's what I want to do. I've got a list of Post ID's that I need to store in specific arrangements, different from their nested order as presented by WordPress. For example:
- ID 101
- ID 106
- ID 115
- ID 116
- ID 107
- ID 117
- ID 108
- ID 118
- ID 119
- ID 120
- ID 109
- ID 106
- ID 102
- ID 110
- ID 121
- ID 122
- ID 111
- ID 123
- ID 112
- ID 110
- ID 103
- ID 113
- ID 114
- ID 104
- ID 105
The idea here is that this is a deep and complex list that could go on recursively forever if needed.
Now I could create a set of nested arrays to house this structure in PHP, but that feels a little sloppy on my end. My question is this: Is there a simpler/cleaner way to store this complex list of nested ID's -- A JSON list, XML list or some other form of data that could be programmatically manipulated as needed?
This is pretty abstract and isn't truly WordPress related, except that I'm storing this data in a WordPress installation, so I am limited to PHP/MySQL-esque parameters.
Here's what I want to do. I've got a list of Post ID's that I need to store in specific arrangements, different from their nested order as presented by WordPress. For example:
- ID 101
- ID 106
- ID 115
- ID 116
- ID 107
- ID 117
- ID 108
- ID 118
- ID 119
- ID 120
- ID 109
- ID 106
- ID 102
- ID 110
- ID 121
- ID 122
- ID 111
- ID 123
- ID 112
- ID 110
- ID 103
- ID 113
- ID 114
- ID 104
- ID 105
The idea here is that this is a deep and complex list that could go on recursively forever if needed.
Now I could create a set of nested arrays to house this structure in PHP, but that feels a little sloppy on my end. My question is this: Is there a simpler/cleaner way to store this complex list of nested ID's -- A JSON list, XML list or some other form of data that could be programmatically manipulated as needed?
Share Improve this question edited Apr 26, 2019 at 4:41 fuxia♦ 107k39 gold badges255 silver badges459 bronze badges asked Apr 25, 2019 at 20:11 BrentBrent 8032 gold badges8 silver badges17 bronze badges1 Answer
Reset to default 0Instead of going for a complex nested array, I decided that it might be best to keep it to simple two level set of arrays.
$x = array(
101 => [ (int $parent_id), (bool $completed) ],
102 => [ (int $parent_id), (bool $completed) ],
103 => [ (int $parent_id), (bool $completed) ],
104 => [ (int $parent_id), (bool $completed) ],
...
);
I realized that I was looking for something simpler like what python offers with its "list" data type. I feel like this is about as simple as I could get with storing an unorder list in PHP/MySQL. Anyone got anything better?
本文标签: databaseI Want a More Concice Form of Data than an Array
版权声明:本文标题:database - I Want a More Concice Form of Data than an Array 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745550785a2662934.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论