diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 7fd63154381..335c885ce40 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -92,6 +92,57 @@ if (! function_exists('json_encode')) } } +if (! function_exists('json_decode')) +{ + /** + * Implement json_decode for PHP that does not support it + * + * @param string $json Json encoded to PHP Object or Array + * @param bool $assoc False return an object, true return an array + * @return mixed Object or Array + */ + function json_decode($json, $assoc=false) + { + $comment = false; + + for ($i=0; $i $value) + { + $object->{$key} = $value; + } + + return $object; + } + + return false; + } + + return $array; + } +} + /** * This function output memory used by PHP and exit everything. Used for debugging purpose.