답변 3개 / 댓글 1개
채택된 답변
+20 포인트
Copy
$test = 123456;
$test_num = strlen($test); //문자열 길이를 구한다
for($i = 0;$i<$test_num;$i++){
$test_value .= substr($test, $i, 1);
if($i+1<$test_num) $test_value .= ',';
}
$test = $test_value;
8년 전
정규식
$test1=12345;
preg_match_all("/[0-9]{1}/", $test1, $match);
$str = implode (',',$match[0]);
echo $str;
8년 전
물론 방법은 다양하겠지만 다음과 같은 방법도 있겠습니다.
Copy
$test = 12345;
$test1 = str_split((string)$test);
$test = implode(",", $test1);
echo $test;
답변에 대한 댓글 1개
답변을 작성하려면 로그인이 필요합니다.