Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

How to divide an array to arrays?

Started by Muut Archive 10 years ago · 1 replies · 460 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 Muut Archive, 10 years ago
1 676 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5337 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago