Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

pixelfear/Statamic-in_array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

in_array

PHP's in_array for Statamic values

If you have an array that looks something like this:

event_days:
  - Mon
  - Tue
  - Wed

You can do something like this: (the modifier way)

{{ if event_day|in_array:Mon }}
  There's an event on monday.
{{ endif }}

or this: (the plugin way)

{{ if {in_array needle="Mon" haystack="{ event_day|option_list }"} }}
  There's an event on monday.
{{ endif }}

or this:

{{ if {in_array needle="{ time|format:D }" haystack="{ event_day|option_list }"} }}
  There's an event today!
{{ endif }}

Notice when using the plugin method, you need to specify your array as an option_list.
Which means event_days|option_list will be Mon|Tue|Wed.

About

PHP's in_array for Statamic values

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages