Update and rename naturename.kr.php to country.kr.php

This commit is contained in:
Namhyeon Go 2019-02-26 16:00:04 +09:00 committed by GitHub
parent fec76384ec
commit da29e3b2c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 55 additions and 25 deletions

55
helper/country.kr.php Normal file
View File

@ -0,0 +1,55 @@
<?php
/**
* @file country.kr.php
* @date 2018-04-15
* @author Go Namhyeon <gnh1201@gmail.com>
* @brief Country Helper (Korean)
*/
// parse telephone number
if(!check_function_exists("get_kr_parsed_tel_number")) {
function get_kr_parsed_tel_number($tel) {
$output = preg_replace("/[^0-9]/", "", $tel); // 숫자 이외 제거
$local_code = substr($tel, 0, 2);
if ($local_code == '02') {
$output = preg_replace("/([0-9]{2})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel);
} elseif (strlen($tel) == '8' && in_array($local_code, array('15', '16', '18'))) {
$output = preg_replace("/([0-9]{4})([0-9]{4})$/", "\\1-\\2", $tel); // 지능망 번호이면
} else {
$output = preg_replace("/([0-9]{3})([0-9]{3,4})([0-9]{4})$/", "\\1-\\2-\\3", $tel);
}
return $output;
}
}
if(!check_function_exists("get_kr_get_lastname")) {
function get_kr_get_lastname()
if(loadHelper("string.utils")) {
$words = split_by_line(read_stroage_file("kr.lastname.txt", array(
"storage_type" => "country",
)));
$prefix_names = explode(",", $words);
shuffle($prefix_names);
return $prefix_names[0];
}
}
}
if(!check_function_exists("get_kr_get_firstname")) {
function get_kr_get_firstname() {
if(loadHelper("string.utils")) {
$words = split_by_line(read_stroage_file("kr.firstname.txt", array(
"storage_type" => "country",
)));
$prefix_names = explode(",", $words);
shuffle($prefix_names);
return $prefix_names[0];
}
}
}
if(!check_function_exists("get_kr_get_generated_name")) {
function get_kr_get_generated_name() {
return sprintf("%s%s", get_kr_get_lastname(), get_kr_get_firstname());
}
}

View File

@ -1,25 +0,0 @@
<?php
/**
* @file naturename.kr.php
* @date 2018-04-15
* @author Go Namhyeon <gnh1201@gmail.com>
* @brief Korean nature name generator
*/
function naturename_kr_get_prefix_name() {
$words = "김,이,박,최,정,강,조,윤,장,임,고";
$prefix_names = explode(",", $words);
shuffle($prefix_names);
return $prefix_names[0];
}
function naturename_kr_get_suffix_name($year="", $gender="") {
$words = "영자,정자,순자,춘자,경자,옥자,명자,숙자,정순,화자,영수,영호,영식,정웅,영길,영일,정수,정남,광수,중수,정숙,영숙,영순,영희,정희,옥순,영철,종수,정식,정호,영환,명숙,경숙,순옥,현숙,성수,성호,상철,경수,상호,미경,미숙,경희,미영,영미,영진,병철,진호,재호,은정,은주,은영,현주,은경,지영,현정,미정,정훈,성훈,성진,상훈,성민,상현,준호,선영,지연,혜진,지훈,민수,지혜,지은,수진,은지,아름,지현,보람,현우,동현,준영,진우,유진,민지,수빈,지원,현지,예진,예지,민석,준혁,승현,서연,민서,서현,서영,수민,예원,민준,민재,도현,현준,승민,지민,서윤,예은,하은,지우,윤서,준서,우진,건우,예준,지후,채원,하윤,지아,은서,서준,주원,시우,도윤";
$suffix_names = explode(",", $words);
shuffle($suffix_names);
return $suffix_names[0];
}
function naturename_kr_get_generated_name() {
return naturename_kr_get_prefix_name() . naturename_kr_get_suffix_name();
}