Used to create lists of countries and states.

Maintainers

👁 spekkionu

Package info

github.com/digital-canvas/options

pkg:composer/digital-canvas/options

Statistics

Installs: 869

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.2 2016-05-22 20:40 UTC

Requires

None

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 2f7dc52be23203103acfba2663826cb300ab9382

  • Jonathan Bernardi <jonathan.woop@digitalcanvas.com>

This package is auto-updated.

Last update: 2026-06-12 16:49:54 UTC


README

👁 Latest Stable Version
👁 Total Downloads
👁 License
👁 Build Status
👁 Scrutinizer Code Quality
👁 Code Coverage
👁 Build Status
👁 SensioLabsInsight

Used to create lists of countries and US and CA states/provinces.

Installation

composer require digital-canvas/options

Usage

Create an array with state abbreviations as keys and full names as values

// US states only
$states = \DigitalCanvas\Options\States::getPairs(['US']);
// US states and CA provinces
$states = \DigitalCanvas\Options\States::getPairs(['US', 'CA']);

Create an array with abbreviations as keys and full array of state data as values

// US states only
$states = \DigitalCanvas\Options\States::getArray(['US']);
// US states and CA provinces
$states = \DigitalCanvas\Options\States::getArray(['US', 'CA']);

Create a <select> list for state selection

<select name="state">
 <?php foreach(\DigitalCanvas\Options\States::getPairs(['US']) as $abbr => $label):?>
 <option value="<?php echo htmlspecialchars($abbr);?>"><?php echo htmlspecialchars($label);?></option>
 <?php endforeach; ?>
</select>