|
...
|
...
|
@@ -245,4 +245,41 @@ class Arr extends \Illuminate\Support\Arr |
|
|
|
}, $arr));
|
|
|
|
return json_encode(array_values(array_unique(array_filter($array))));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 数组转文本html数组
|
|
|
|
* @param $array
|
|
|
|
* @param $indentLevel
|
|
|
|
* @return array
|
|
|
|
* @author zbj
|
|
|
|
* @date 2025/9/26
|
|
|
|
*/
|
|
|
|
public static function formatForHtml($array, $indentLevel = 0) {
|
|
|
|
$result = [];
|
|
|
|
$indent = str_repeat(' ', $indentLevel);
|
|
|
|
|
|
|
|
foreach ($array as $key => $value) {
|
|
|
|
$isNumericKey = is_numeric($key);
|
|
|
|
|
|
|
|
if (is_array($value)) {
|
|
|
|
if (!$isNumericKey) {
|
|
|
|
$result[] = "{$indent}{$key}:<br/>";
|
|
|
|
$nestedResult = self::formatForHtml($value, $indentLevel + 1);
|
|
|
|
} else {
|
|
|
|
$key && $result[] = '<br/>';
|
|
|
|
$nestedResult = self::formatForHtml($value, $indentLevel);
|
|
|
|
}
|
|
|
|
$result = array_merge($result, $nestedResult);
|
|
|
|
} else {
|
|
|
|
if ($isNumericKey) {
|
|
|
|
$result[] = "{$indent}{$value}<br/>";
|
|
|
|
} else {
|
|
|
|
$result[] = "{$indent}{$key}: {$value}<br/>";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|