함수 email2local

Jmnote bot (토론 | 기여)님의 2020년 11월 2일 (월) 02:36 판 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)
함수 email2local

1 Bash[ | ]

Bash
Copy
email=helloworld@example.com
local=`echo $email | cut -d@ -f1`
echo $local
# helloworld

2 PHP[ | ]

PHP
Copy
$email = 'helloworld@example.com';
$local = array_shift(explode('@', $email));
echo $local;
// helloworld
PHP
Copy
function email2local($email) {
	$arr = explode('@', $email);
	if( count($arr) != 2 ) return false;
	return array_shift( $arr );
}
$email = 'helloworld@example.com';
echo email2local( $email );
// helloworld

3 같이 보기[ | ]