The following are specific applications of PHP JSON encryption 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;
- }
希望通过上面这段代码的演示,大家能够充分掌握PHP JSON加密函数的用法,帮助自己完善代码编程。
http://www.bkjia.com/PHPjc/446100.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/446100.htmlTechArticle以下为PHP JSON加密函数的具体应用: functionphp_json_encode($arr) { $ json_str = ; if(is_array($arr)) { $ pure_array = true ; $ array_length = count ($arr); for($ i = 0...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn