The following are the specific applications of PHP JSON cryptographic functions:
- function Php_json_encode ($arr)
- {
- $ Json_str = "" ;
- if (Is_array ($arr))
- {
- $ Pure_array = true ;
- $ Array_length = Count ($arr);
- For ($i=0; $i<$array _length; $i + +)
- {
- if (! isset ($arr [$i]))
- {
- $ Pure_array = false ;
- Break
- }
- }
- if ($pure _array)
- {
- $ Json_str = "[";
- $ Temp = Array ();
- For ($i=0; $i<$array _length; $i + +)
- {
- $temp [] = sprintf ("%s", Php_json_encode ($arr [$i]);
- }
- $json _str . = implode (",", $temp);
- $json _str . = "]";
- }
- Else
- {
- $ Json_str = "{";
- $ Temp = Array ();
- foreach ($arr as $key => $value)
- {
- $temp [] = sprintf ("" "%s":%s ", $key, Php_json_encode ($value));
- }
- $json _str . = implode (",", $temp);
- $json _str . = "}";
- }
- }
- Else
- {
- if (is_string ($arr))
- {
- $ Json_str = "" ". Json_encode_string ($arr). """;
- }
- else if (Is_numeric ($arr))
- {
- $ Json_str = $arr;
- }
- Else
- {
- $ Json_str = "" ". Json_encode_string ($arr). """;
- }
- }
- return $json _str;
- }
Hope that through the above code demonstration, you can fully grasp the PHP JSON cryptographic function usage, to help you improve code programming.
http://www.bkjia.com/PHPjc/446100.html www.bkjia.com true http://www.bkjia.com/PHPjc/446100.html techarticle The following is the specific application of the PHP JSON cryptographic function: Functionphp_json_encode ($arr) {$ json_str =; if (Is_array ($arr)) {$ pure_array = true; $ arra Y_length = count ($arr); for ($ i = 0 ...