랜덤 이밎(IMG) 출력 질문 채택완료
</font></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><code class="plain" style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em; background-image: none; margin: 0px; padding: 0px; border: 0px; float: none; vertical-align: baseline; height: auto; width: auto; line-height: 1.8em;"><?</code></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><code class="plain" style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em; background-image: none; margin: 0px; padding: 0px; border: 0px; float: none; vertical-align: baseline; height: auto; width: auto; line-height: 1.8em;">$eximg = mt_rand(1,3);</code></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><code class="plain" style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em; background-image: none; margin: 0px; padding: 0px; border: 0px; float: none; vertical-align: baseline; height: auto; width: auto; line-height: 1.8em;">if(</code><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;">$eximg==1</span><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em;">) </span><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;">$ex_img = 'gif';</span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><code class="plain" style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em; background-image: none; margin: 0px; padding: 0px; border: 0px; float: none; vertical-align: baseline; height: auto; width: auto; line-height: 1.8em;">else if(</code><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;">$eximg==2</span><span style="font-size: 1em; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;">) </span><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;">$ex_img = 'jpg';</span><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;"> </span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><span style="font-size: 1em; font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;">else </span><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;">$ex_img = 'png';</span><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;"> </span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;">?></span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: 돋움, Dotum, sans-serif; font-size: 14.004px;"><code class="plain" style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em; background-image: none; margin: 0px; padding: 0px; border: 0px; float: none; vertical-align: baseline; height: auto; width: auto; line-height: 1.8em;"><img src=</code><code class="string" style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em; background-image: none; margin: 0px; padding: 0px; border: 0px; float: none; vertical-align: baseline; height: auto; width: auto; line-height: 1.8em; color: rgb(0, 0, 255);">"img/<?php echo mt_rand(1, 2200)?>.<span style="font-size: 14.6667px;"><?php echo $ex_img?></span>"</code><code class="plain" style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 1em; background-image: none; margin: 0px; padding: 0px; border: 0px; float: none; vertical-align: baseline; height: auto; width: auto; line-height: 1.8em;">/></code><span style="font-family: Consolas, "Bitstream Vera Sans Mono", "Courier New", Courier, monospace; font-size: 14.6667px;">
1.gif ~ 1000.gif
1001.jpg ~ 1500.jpg
1501.png ~ 1600.png
이런식으로 구성이 되어있는데 어떻게 고쳐야 될까요?
답변 1개
</p><p><?php</p><p>$num = mt_rand(1,1600);</p><p> </p><p>if($num <= 1000)</p><p> $img = $num . "gif";</p><p>else if($num <=1500)</p><p> $img = $num . "jpg";</p><p>else if($num <=1600)</p><p> $img = $num . "png";</p><p>?></p><p><font face="GulimChe"><img src=<code class="php string">"img/<?=<font face="돋움">$img?></font>"</code></font><code class="php plain"><font face="GulimChe">/></font> </code></p><p>
답변에 대한 댓글 2개
<?php
$num = mt_rand(1,1601);
if($num <= 1000)
$img = $num . "gif";
else if($num <=1500)
$img = $num . "jpg";
else if($num <=1600)
$img = $num . "png";
else if($num <=1601)
$img = $num . "png";
?>
<?php
if ($num == 1601)
{
?>
<a href="http://naver.com"><img src="img/<?=$img?>"/></a>
<?
}
else
{
?>
<img src="img/<?=$img?>"/>
<?
}
?>
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
$num = mt_rand(1,1601);
if($num <= 1000)
$img = $num . "gif";
else if($num <=1500)
$img = $num . "jpg";
else if($num <=1600)
$img = $num . "png";
else if($num <=1601)
$img = $num . "png";
?>
<img src="img/<?=$img?>"/>
1601번 이미지는 <a href="http://naver.com"> 넣고싶은데 어떻게 해야될까요?