초보의 질문입니다. 숫자 정렬
<?
for($i=1; $i<46; $i++) {
$i = sprintf("%02d",$i);
$lotto[$i] = $i;
}
shuffle($lotto);
echo "<font color=pink></font> ";
echo $lotto[0]." <font color=silver> </font> ".$lotto[1]." <font color=silver> </font> ".$lotto[2]." <font color=silver> </font> ".$lotto[3]." <font color=silver> </font> ".$lotto[4]." <font color=silver> </font> ".$lotto[5];
?>
로또번호 자동생성 소스인데요. 숫자가 정렬이 되게 하려합니다.
42 25 06 27 45 01 -> 01 06 25 27 42 45 이런식으로요. 부탁드립니다. ^^<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
for($i=1; $i<46; $i++) {
$i = sprintf("%02d",$i);
$lotto[$i] = $i;
}
shuffle($lotto);
echo "<font color=pink></font> ";
echo $lotto[0]." <font color=silver> </font> ".$lotto[1]." <font color=silver> </font> ".$lotto[2]." <font color=silver> </font> ".$lotto[3]." <font color=silver> </font> ".$lotto[4]." <font color=silver> </font> ".$lotto[5];
?>
로또번호 자동생성 소스인데요. 숫자가 정렬이 되게 하려합니다.
42 25 06 27 45 01 -> 01 06 25 27 42 45 이런식으로요. 부탁드립니다. ^^<div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]</div>
댓글 4개
14년 전
<?
for($i=1; $i<46; $i++) {
$i = sprintf("%02d",$i);
$lotto[$i] = $i;
}
$lotto = array_rand($lotto,6);
echo "<font color=pink></font> ";
echo $lotto[0]." <font color=silver> </font> ".$lotto[1]." <font color=silver> </font> ".$lotto[2]." <font color=silver> </font> ".$lotto[3]." <font color=silver> </font> ".$lotto[4]." <font color=silver> </font> ".$lotto[5];
?>
for($i=1; $i<46; $i++) {
$i = sprintf("%02d",$i);
$lotto[$i] = $i;
}
$lotto = array_rand($lotto,6);
echo "<font color=pink></font> ";
echo $lotto[0]." <font color=silver> </font> ".$lotto[1]." <font color=silver> </font> ".$lotto[2]." <font color=silver> </font> ".$lotto[3]." <font color=silver> </font> ".$lotto[4]." <font color=silver> </font> ".$lotto[5];
?>
14년 전
사하님 너무 감사드립니다.
그런데 이상하게 새로고침하면 또 정렬이 난되는듯하네요. ㅡ.ㅡ
너무 감사드립니다.
추가로 혹시
숫자 생성시 1~9는 앞에 0을 붙혀서 출력하려면 어떻게 해야하는지요?
<?
$arr = range(1,45);
shuffle($arr);
$arr_out = array_slice($arr,0,6);
sort($arr_out);
echo implode(" ",$arr_out);
?>
위 소스를 출력하면 1,2,11,13,15,16 이렇게 단번호에는 0이 안붙네요. ^^
즐거운 하루 되세요.
그런데 이상하게 새로고침하면 또 정렬이 난되는듯하네요. ㅡ.ㅡ
너무 감사드립니다.
추가로 혹시
숫자 생성시 1~9는 앞에 0을 붙혀서 출력하려면 어떻게 해야하는지요?
<?
$arr = range(1,45);
shuffle($arr);
$arr_out = array_slice($arr,0,6);
sort($arr_out);
echo implode(" ",$arr_out);
?>
위 소스를 출력하면 1,2,11,13,15,16 이렇게 단번호에는 0이 안붙네요. ^^
즐거운 하루 되세요.
14년 전
<?
$arr = range(1,45);
shuffle($arr);
$arr_out = array_slice($arr,0,6);
sort($arr_out);
foreach($arr_out as $arr_str)
{
echo sprintf("%02d",$arr_str)." ";
}
?>
$arr = range(1,45);
shuffle($arr);
$arr_out = array_slice($arr,0,6);
sort($arr_out);
foreach($arr_out as $arr_str)
{
echo sprintf("%02d",$arr_str)." ";
}
?>
14년 전
감사합니다. 완벽하게 해결됬습니다.
사하님 정말 감사합니다. ^^
사하님 정말 감사합니다. ^^
게시판 목록
퍼블리셔팁
퍼블리싱과 관련된 유용한 정보를 공유하세요.
질문은 상단의 QA에서 해주시기 바랍니다.
질문은 상단의 QA에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 1217 | 반응형 | 3년 전 | 3105 | ||
| 1216 | 웹접근성 | 3년 전 | 2498 | ||
| 1215 | CSS | 4년 전 | 4904 | ||
| 1214 | 기타 | 4년 전 | 8363 | ||
| 1213 | CSS | 4년 전 | 3256 | ||
| 1212 | 웹접근성 | 4년 전 | 3644 | ||
| 1211 | CSS |
|
5년 전 | 4121 | |
| 1210 | 기타 | 5년 전 | 3346 | ||
| 1209 | CSS | 5년 전 | 3595 | ||
| 1208 | 기타 | 5년 전 | 3152 | ||
| 1207 | 기타 | 5년 전 | 2894 | ||
| 1206 | CSS |
moviepd
|
5년 전 | 3722 | |
| 1205 | HTML |
moviepd
|
5년 전 | 4386 | |
| 1204 | 기타 | 6년 전 | 7838 | ||
| 1203 | 웹접근성 | 6년 전 | 3014 | ||
| 1202 | 기타 | 6년 전 | 2990 | ||
| 1201 | 기타 | 6년 전 | 4327 | ||
| 1200 | 기타 | 6년 전 | 4124 | ||
| 1199 | 기타 | 6년 전 | 4135 | ||
| 1198 | 기타 | 6년 전 | 2616 | ||
| 1197 | 기타 | 6년 전 | 2689 | ||
| 1196 | 기타 | 6년 전 | 2471 | ||
| 1195 | 기타 | 6년 전 | 2460 | ||
| 1194 | 기타 | 6년 전 | 3049 | ||
| 1193 | 기타 | 6년 전 | 9237 | ||
| 1192 | 기타 | 6년 전 | 3886 | ||
| 1191 | 기타 | 6년 전 | 6226 | ||
| 1190 | 기타 | 6년 전 | 2445 | ||
| 1189 | 기타 | 6년 전 | 2347 | ||
| 1188 | 기타 | 6년 전 | 1826 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기