* zin: refactor, move unHTMLArray helper to zin/utils/json.func.

This commit is contained in:
sunhao
2024-01-29 22:33:01 +08:00
parent f92d5c3356
commit dffc222e9a
2 changed files with 23 additions and 24 deletions
-24
View File
@@ -739,27 +739,3 @@ function getVisions(): array
$visionList = $lang->visionList;
return array_intersect_key($visionList, $visions);
}
/**
* 对数据进行HTML实体转为字符。
* Un HTML array.
*
* @param mixed $data
* @access public
* @return mixed
*/
function unHTMLArray($data, $processed = array())
{
if(is_string($data)) return htmlspecialchars_decode($data);
if(is_array($data) || is_object($data))
{
if(in_array($data, $processed, true)) {
return $data;
}
$processed[] = $data;
foreach($data as &$value) $value = unHTMLArray($value, $processed);
}
return $data;
}
+23
View File
@@ -2,6 +2,29 @@
declare(strict_types=1);
namespace zin\utils;
/**
* 对数据进行HTML实体转为字符。
* Un HTML array.
*
* @param mixed $data
* @access public
* @return mixed
*/
function unHTMLArray($data, $processed = array())
{
if(is_string($data)) return htmlspecialchars_decode($data);
if(is_array($data) || is_object($data))
{
if(in_array($data, $processed, true)) return $data;
$processed[] = $data;
foreach($data as &$value) $value = unHTMLArray($value, $processed);
}
return $data;
}
function jsonEncode($data, $flags = 0, $depth = 512): string|false
{
$data = unHTMLArray($data);