diff options
author | Florian Pritz <bluewind@xinu.at> | 2017-07-04 11:58:38 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2017-07-04 12:10:49 +0200 |
commit | 56f176309428541e6868cb9c4a89f51f5cbdd2f8 (patch) | |
tree | 2aa5a7fde0ebaa28380330ca77c08a5bb76cf613 /application/helpers | |
parent | 9bdf0973b337cbf73287422cc5fdceabc8703e61 (diff) |
Create function for ensuring that json keys contain objects
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application/helpers')
-rw-r--r-- | application/helpers/filebin_helper.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 55fdf773d..c1a6f4f96 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -383,4 +383,13 @@ function return_bytes($size_str) } } +function ensure_json_keys_contain_objects($data, $keys) { + foreach ($keys as $key) { + if (empty($data[$key])) { + $data[$key] = (object) array(); + } + } + return $data; +} + # vim: set noet: |