PHPackages                             highland/statamic-array-get - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. highland/statamic-array-get

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

highland/statamic-array-get
===========================

Laravel's array\_get() / Arr::get() helper for Statamic.

1.0.0(5y ago)11.5k↓50%PHP

Since Sep 8Pushed 5y ago2 watchersCompare

[ Source](https://github.com/HighlandSolutions/statamic-array-get)[ Packagist](https://packagist.org/packages/highland/statamic-array-get)[ RSS](/packages/highland-statamic-array-get/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Statamic Array Get
==================

[](#statamic-array-get)

[![Image depicting Antlers template syntax for this addon](./array_get.png)](./array_get.png)

This addon helps you **DRY up your templates** with a tag that makes it trivial to output data nested in arrays with variable keys.

For the Laravel devs out there, this works very similarly to the [`Arr::get()`](https://laravel.com/docs/8.x/helpers#method-array-get) (or the old `array_get()`) helper.

[Looking for the docs?](./DOCUMENTATION.md)

Why?
----

[](#why)

I use it most often to **simplify markup for component variants**.

For example, on [Highland's website](https://highlandsolutions.com/) we use several different color variants for our navbar and logo. Each variant requires setting several classes across six elements.

  Rather than repeating markup with slight differences… ```

{{ if navbar_variant === 'blue_tan_pink' }}

        {{ partial:components/svg/logo
            p_logo_type_class     ="text-tan-200"
            p_logo_crossbar_class ="text-pink-400"
        }}

        {{ links }}

        {{ /links }}

{{ elseif navbar_variant === 'blue_tan_peach' }}

        {{ partial:components/svg/logo
            p_logo_type_class     ="text-tan-200"
            p_logo_crossbar_class ="text-peach-300"
        }}

        {{ links }}

        {{ /links }}

{{ /if }}
```

  …or a bunch of conditionals inside class attributes… ```
