$value) { if (strpos($words, $separator) !== false) { $words = $separator . str_replace($separator, " ", strtolower($words)); $result[ltrim(str_replace(" ", "", ucwords($words)), $separator)] = $value; } else { $result[$words] = $value; } } } return $result; } /** * 根据 code 获取 name * @param $code * @param array $data * @return mixed|null */ public static function getEnumNameByCode($code, array $data = []) { foreach ($data as $datum) { if (isset($datum['code']) && isset($datum['name']) && $datum['code'] === $code) { return $datum['name']; } } return null; } /** * 获取数组维度 几维数组 * @param $array * @return int */ public static function array_depth($array): int { if (!is_array($array)) return 0; $max_depth = 1; foreach ($array as $value) { if (is_array($value)) { $depth = self::array_depth($value) + 1; if ($depth > $max_depth) { $max_depth = $depth; } } } return $max_depth; } }