Radical Design Course by Jack McDade

From the creator of Statamic

Learn how to make your websites standout and be remembered.

Bought Jack McDade's course on design. Going through it now...and it is SO well done!

— Justin Jackson, Transistor.fm

flatten Modifier

Flattens a multi-dimensional array (a Grid or Replicator field for example) into a single dimension.

ingredients:
spices: [garlic, cumin, ginger, turmeric, paprika, curry powder]
vegetables: [tomatoes, onion]
meat: [chicken]
{{ ingredients | flatten }}
<?php
$flattened = Statamic::modify($ingredients)
->flatten()
->fetch();
?>
ingredients:
- garlic
- cumin
- ginger
- turmeric
- paprika
- curry powder
- tomatoes
- onion
- chicken

You can optionally pass a depth parameter to the flatten modifier, allowing you to specify how deeply nested arrays should be flattened.

-
- garlic
- cumin
- ginger
- turmeric
- paprika
- curry powder
-
- tomatoes
- onion
-
- chicken
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →