Created
January 8, 2018 10:04
-
-
Save Gkiokan/48faa4a1df16054e9e60d4117fdd46f0 to your computer and use it in GitHub Desktop.
JSON full encode decode with UTF-8 support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Data Class | |
* * * * * * * | |
Author: Gkiokan | |
Comment: | |
Encode and Decode Your String / Object / Array with utf-8 force. | |
*/ | |
class Data { | |
// Encode | |
// @param $a Array Element to decode in JSON | |
public static function encode($a=[]){ | |
$json = json_encode($a, JSON_UNESCAPED_UNICODE); | |
return $json; | |
} | |
// Decode | |
// @param $a JSON String | |
// @param $t Type of return (false = Array, true = Object) | |
public static function decode($a='', $t=false){ | |
$obj = json_decode($a, $t, 512, JSON_UNESCAPED_UNICODE); | |
return $obj; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment