# Structure get/find/request entry by keyname

**URL:** <https://forum.getkirby.com/t/structure-get-find-request-entry-by-keyname/21682>\
**Category:** Questions\
**Tags:** v3\
**Created:** [March 19, 2021, 9:15pm UTC](https://forum.getkirby.com/t/structure-get-find-request-entry-by-keyname/21682 "2021-03-19T21:15:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jash](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jash/32/2173_2.png) [@jash](https://forum.getkirby.com/u/jash)\
**Post date:** [March 19, 2021, 9:15pm UTC](https://forum.getkirby.com/t/structure-get-find-request-entry-by-keyname/21682/1 "2021-03-19T21:15:16Z")

</div>

Hey - maybe I’m blind, but I didn’t find a build-in-solution in the docs or in this forum to a get a specific entry from a structure field. For example I use the structure field to create a dictionary like:

```javascript
// blueprints/site.yml 

dictionary:
   type: structure
   fields:
      key:
        type: text
      value:
        type: text

```

Now, in the templates I would like to have a method to get a specific entry by `key` like this:

```php
$site->dictionary()->toStructure()->findEntryByKey("[A UNIQUE KEY]")->value()

```

I tried it with`toStructure()->get()` and `toStructure()->filterBy()` but without success.

One more important question: Are the word `key` and `value` reserved by Kirby, or can this words be used like in the example above?

Thanks for your help

---

<div class="post-metadata">

**Author:** ![ahmetbora](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/ahmetbora/32/11671_2.png) [@ahmetbora](https://forum.getkirby.com/u/ahmetbora)\
**Post date:** [March 19, 2021, 9:23pm UTC](https://forum.getkirby.com/t/structure-get-find-request-entry-by-keyname/21682/2 "2021-03-19T21:23:15Z")

</div>

I think it will work in the example below:

```php
if ($row = $site->dictionary()->toStructure()->findBy("key", "something")) {
    echo $row->value();
}

```

About reserved method names:

> **[Fields](https://getkirby.com/docs/guide/blueprints/fields#naming-fields)**

---

<div class="post-metadata">

**Author:** ![jash](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/jash/32/2173_2.png) [@jash](https://forum.getkirby.com/u/jash)\
**Post date:** [March 19, 2021, 10:47pm UTC](https://forum.getkirby.com/t/structure-get-find-request-entry-by-keyname/21682/3 "2021-03-19T22:47:11Z")

</div>

Thanks - this works perfectly.

In the meantime I found another solution I like to share. Maybe it is working out for someone too.  
I converted the indexed array from the structure field (via `->yaml()`) into an associated array. After that, i got the shortest way to access a value by a key:

```php
$associativeDictionary= [];
foreach ($site->dictionary()->yaml() as $row) {
    $associativeDictionary[$row['key']] = $row["value"];
}
$valueByKey = $associativeDictionary["some-key"]

```

I stored `$associativeDictionary` in the `controller/site.php` and have easy access to all entries everywhere – including “nice” errors, if a key is not defined 😉
