초보의 질문입니다. 숫자 정렬
<?
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에서 해주시기 바랍니다.
| 번호 | 분류 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|---|
| 1187 | 기타 | 6년 전 | 2276 | ||
| 1186 | 기타 | 6년 전 | 2109 | ||
| 1185 | 기타 | 6년 전 | 2109 | ||
| 1184 | 기타 | 6년 전 | 2115 | ||
| 1183 | 기타 | 6년 전 | 1872 | ||
| 1182 | 기타 | 6년 전 | 2156 | ||
| 1181 | 기타 | 6년 전 | 1741 | ||
| 1180 | 기타 | 6년 전 | 1943 | ||
| 1179 | 기타 | 6년 전 | 2145 | ||
| 1178 | 기타 | 6년 전 | 2233 | ||
| 1177 | 기타 | 6년 전 | 1766 | ||
| 1176 | 기타 | 6년 전 | 1622 | ||
| 1175 | 기타 | 6년 전 | 2093 | ||
| 1174 | 기타 | 6년 전 | 1658 | ||
| 1173 | 기타 | 6년 전 | 1501 | ||
| 1172 | 기타 | 6년 전 | 1684 | ||
| 1171 | 기타 | 6년 전 | 1375 | ||
| 1170 | 기타 | 6년 전 | 1558 | ||
| 1169 | 기타 | 6년 전 | 1291 | ||
| 1168 | 기타 | 6년 전 | 1413 | ||
| 1167 | 기타 | 6년 전 | 1282 | ||
| 1166 | 기타 | 6년 전 | 1600 | ||
| 1165 | 기타 | 6년 전 | 1343 | ||
| 1164 | 기타 | 6년 전 | 1659 | ||
| 1163 | 기타 | 6년 전 | 1630 | ||
| 1162 | 기타 | 6년 전 | 1589 | ||
| 1161 | 기타 | 6년 전 | 3424 | ||
| 1160 | 기타 | 6년 전 | 3100 | ||
| 1159 | 기타 | 7년 전 | 2214 | ||
| 1158 | 기타 | 7년 전 | 1908 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기