Skip to content

Commit

Permalink
Added Assoc array support (#1)
Browse files Browse the repository at this point in the history
* Added support for outputting an assoc array

PHP's implementation of json_decode also supports an $assoc param that allows you to output an associative array instead of an object.

* some proper formatting

* Update README.md
  • Loading branch information
ryanirelan authored and diit committed Sep 24, 2017
1 parent f72244e commit e859bcb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 10 additions & 1 deletion README.md
Expand Up @@ -44,4 +44,13 @@ Add extra data to fields like multiselect, in this example add icons from multip
{% endfor %}
</div>
```
[Dale Inverarity](http://dale.wtf/) © 2015 - All rights reserved

## Options

By default `json_decode` outputs an object but you can also output an associative array by passing `true` as a parameter value to the filter.

```php
{% set icon = rawicon | json_decode(true) %}
```

[Dale Inverarity](http://dale.wtf/) © 2015 - All rights reserved
Expand Up @@ -25,8 +25,8 @@ public function getFilters() {
return $returnArray;
}

public function json_decode($json) {
public function json_decode($json, $assoc = false) {

return json_decode($json);
return json_decode($json, $assoc);
}
}
}

0 comments on commit e859bcb

Please sign in to comment.