PHPackages                             hansel23/dictionaries - 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. hansel23/dictionaries

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

hansel23/dictionaries
=====================

Dictionary with interface. It's losely based on the Dictionary type of other famous languages. Strict typed.

v1.0.8(10y ago)0589MITPHPPHP &gt;=5.5

Since May 18Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Hansel23/Dictionaries)[ Packagist](https://packagist.org/packages/hansel23/dictionaries)[ RSS](/packages/hansel23-dictionaries/feed)WikiDiscussions master Synced yesterday

READMEChangelog (9)Dependencies (2)Versions (11)Used By (0)

[![Build Status](https://camo.githubusercontent.com/94ae119fc128fcf28d7ce33c9f99cc369fbf0529f8be98a63a745f2228f05da3/68747470733a2f2f7472617669732d63692e6f72672f48616e73656c32332f44696374696f6e61726965732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Hansel23/Dictionaries)[![Coverage Status](https://camo.githubusercontent.com/20a96395aee2f7b91acafa7466aa983f7bd55497be91692af0bb06b05b18b4b3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f48616e73656c32332f44696374696f6e61726965732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Hansel23/Dictionaries?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/c18fef129600a740594d8147c9576d908a7163fe601100cc2b5adafb52e322af/68747470733a2f2f706f7365722e707567782e6f72672f68616e73656c32332f64696374696f6e61726965732f762f737461626c65)](https://packagist.org/packages/hansel23/dictionaries)[![Latest Unstable Version](https://camo.githubusercontent.com/350d4ba3647e7b5b7c7d1cace6e4b9003c6d0183a2f23bfba816abc832e327f7/68747470733a2f2f706f7365722e707567782e6f72672f68616e73656c32332f64696374696f6e61726965732f762f756e737461626c65)](https://packagist.org/packages/hansel23/dictionaries)[![Total Downloads](https://camo.githubusercontent.com/d0886cc1835ddfc558294b2bbe6e70bb7c511046362e2a2df3558c0cfdd4a93e/68747470733a2f2f706f7365722e707567782e6f72672f68616e73656c32332f64696374696f6e61726965732f646f776e6c6f616473)](https://packagist.org/packages/hansel23/dictionaries)[![License](https://camo.githubusercontent.com/b0e5d68f3ef6aed010bba6c0056deba270f3397ec24eb877cf7afc835c5c91fb/68747470733a2f2f706f7365722e707567782e6f72672f68616e73656c32332f64696374696f6e61726965732f6c6963656e7365)](https://packagist.org/packages/hansel23/dictionaries)

Dictionary
==========

[](#dictionary)

Dictionary Type. Keys and values are strongly typed, so you will know what you get.

Usage
-----

[](#usage)

Immagine you have a class with member data called Member. A member has a firstnamer, lastname and an age. To identify a member you have the type MemberId.

Now you want to have an array where you can put the members into. Now it's a nice idea to get the member information of a specific member by accessing the array with the MemberId. But you can't set the MemberId as the key.

With the Dictionary type this problem is history!

You simply create a Dictionary with the MemberId as the key and the Member as the value like this:

```

```

Now you can add your members to the dictionary like this:

```

```

Where $memberId is of the type MemberId and $member of the type Member.

But you can also add a member with the identifier like you can add a normal key-value-pair (string/int) in a normal array.

```

```

**Notice: Your IDE may mark it as an error, but the code will run properly!**

Now if you filled your dictionary with members you can do following:

```
