$c) {
$pattern = '/[\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}]+/u';
preg_match_all($pattern, $c, $match);
$cut[$k] = is_array($match[0]) ? implode(' ', $match[0]) : $match[0];
}
return implode(' ', array_filter($cut));
}
function getMetaTitle($translate)
{
$page = explode('/', uri_string());
return $translate[$page[count($page) - 1]];
}
function cleanUrl($string)
{
$string = preg_replace('/[^\x{1100}-\x{11FF}\x{3130}-\x{318F}\x{AC00}-\x{D7AF}\-a-zA-Z0-9]+/u', '', str_replace(' ', '-', trim($string)));
$string = preg_replace('/(u[0-9a-f]{4})+/', "", $string);
$string = stripall(['--', '--'], '-', trim($string));
$string = substr($string, 0, 1) == '-' ? substr($string, 1) : $string;
return substr($string, -1) == '-' ? substr($string, 0, -1) : $string;
}
function stripall($values, $replace, $string)
{
foreach ($values as $value) {
while (strpos($string, $value)) {
$string = str_replace($value, $replace, $string);
stripall($values, $replace, $string);
}
}
return $string;
}
function imgSrc($img)
{
if (is_array($img)) {
$path = $img[1];
return '
]*?src *= *[\"']?([^\"']*)/i", 'imgSrc', $content);
}
function getPathWithHost($path, $https = true)
{
$path = trim($path);
$host = ENVIRONMENT == 'development' ? 'crossmap.christiandaily.co.kr' : $_SERVER['HTTP_HOST'];
if ($path) {
return strpos($path, '://') ? $path : 'http' . ($https ? 's' : '') . '://' . $host . '/static' . (substr($path, 0, 1) != '/' ? '/' . $path : $path);
}
return '';
}
function array_flatten($array)
{
if (!is_array($array)) {
return false;
}
$result = array();
foreach ($array as $key => $value) {
if (is_array($value)) {
$result = array_merge($result, array_flatten($value));
} else {
$result[$key] = $value;
}
}
return $result;
}
function time_elapsed_string($datetime, $full = false)
{
$now = new DateTime;
$ago = new DateTime($datetime);
$diff = $now->diff($ago);
$diff->w = floor($diff->d / 7);
$diff->d -= $diff->w * 7;
$string = array(
'y' => '년',
'm' => '개월',
'w' => '주',
'd' => '일',
'h' => '시간',
'i' => '분',
's' => '초',
);
foreach ($string as $k => &$v) {
if ($diff->$k) {
$v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? '' : '');
} else {
unset($string[$k]);
}
}
if (!$full) {
$string = array_slice($string, 0, 1);
}
return $string ? implode(', ', $string) . ' 전' : '방금전';
}
function param($key)
{
return get_instance()->param($key);
}
function go($go, $msg = '')
{
echo '';
}