초보의 질문입니다. 숫자 정렬
<?
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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 497 | HTML | 14년 전 | 3437 | ||
| 496 | HTML |
피디인사이드
|
14년 전 | 2888 | |
| 495 | HTML |
wgarlic
|
14년 전 | 5875 | |
| 494 | HTML |
또치2009
|
14년 전 | 2431 | |
| 493 | HTML | 14년 전 | 2446 | ||
| 492 | HTML | 14년 전 | 2919 | ||
| 491 | HTML |
techer
|
14년 전 | 1924 | |
| 490 | HTML | 14년 전 | 2379 | ||
| 489 | HTML |
|
14년 전 | 3183 | |
| 488 | HTML |
level999
|
14년 전 | 2419 | |
| 487 | HTML | 14년 전 | 2420 | ||
| 486 | HTML | 14년 전 | 3751 | ||
| 485 | HTML | 14년 전 | 2506 | ||
| 484 | HTML | 14년 전 | 2156 | ||
| 483 | HTML | 14년 전 | 2562 | ||
| 482 | HTML |
gtm100
|
14년 전 | 2161 | |
| 481 | HTML | 14년 전 | 2509 | ||
| 480 | HTML | 14년 전 | 2579 | ||
| 479 | HTML |
매너천사12
|
14년 전 | 2782 | |
| 478 | HTML | 14년 전 | 2175 | ||
| 477 | HTML |
플레이디원
|
14년 전 | 4245 | |
| 476 | HTML |
berry
|
14년 전 | 3155 | |
| 475 | HTML | 14년 전 | 3059 | ||
| 474 | HTML | 14년 전 | 2251 | ||
| 473 | HTML | 14년 전 | 2642 | ||
| 472 | HTML | 14년 전 | 5347 | ||
| 471 | HTML | 14년 전 | 2003 | ||
| 470 | HTML |
아놔6636
|
14년 전 | 3476 | |
| 469 | HTML | 14년 전 | 1957 | ||
| 468 | HTML |
아놔6636
|
14년 전 | 6550 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기