Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How to divide an array to arrays?

Started by Muut Archive 10 years ago · 1 replies · 323 views
10 years ago

We have an array where we have 10 objects (pages). Each object (page) has a header attribute. Some unique, some are not. We need to break this array so that we will have so much arrays as there are different page header attributes. Milk, Sand, Bread etc are page header attributes.

Now:
---yaml
Array[]:
Milk
Bread
Sand
Car
Milk
Sand

TXT

We need:
---yaml
Array[]:
   Milk
   Milk
Array[]:
   Sand
   Sand
Array[]:
   Car
Array[]: 
   Bread

etc.

We already know how to exclude duplicates. But how to divide them?

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1366 9 years ago
Archive · by Muut Archive, 9 years ago
2 940 9 years ago
Archive · by Muut Archive, 9 years ago
2 4069 9 years ago
Archive · by Muut Archive, 9 years ago
1 2960 9 years ago
Archive · by Muut Archive, 9 years ago
3 1125 9 years ago