php로 중복되지 않는 랜덤 이미지 여러개를 추출하기 위해 배열과 셔플을 썼는데 안됩니다 채택완료
april44
11년 전
조회 8,482
</div>
<div><html></div>
<div><head></div>
<div></head></div>
<div><body></div>
<div><?php</div>
<div>
</div>
<div>$images = array</div>
<div> ('<a href="http://example.com/1.png'," target="_blank" rel="noopener noreferrer">http://example.com/1.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/2.png'," target="_blank" rel="noopener noreferrer">http://example.com/2.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/3.png'," target="_blank" rel="noopener noreferrer">http://example.com/3.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/4.png'," target="_blank" rel="noopener noreferrer">http://example.com/4.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/5.png'," target="_blank" rel="noopener noreferrer">http://example.com/5.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/6.png'," target="_blank" rel="noopener noreferrer">http://example.com/6.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/7.png'," target="_blank" rel="noopener noreferrer">http://example.com/7.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/8.png'," target="_blank" rel="noopener noreferrer">http://example.com/8.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/9.png'," target="_blank" rel="noopener noreferrer">http://example.com/9.png',</a></div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>'<a href="http://example.com/10.png');" target="_blank" rel="noopener noreferrer">http://example.com/10.png');</a></div>
<div>
</div>
<div>
</div>
<div>shuffle($images);</div>
<div>
</div>
<div>for($i=0; $i<5; $i++) </div>
<div>
</div>
<div>{</div>
<div><span class="Apple-tab-span" style="white-space: pre"> </span>echo '<img src="'.$images[$i].'"/>';</div>
<div>}</div>
<div>
</div>
<div>?></div>
<div>
</div>
<div></body></div>
<div></html></div>
<div>
왜 안돌아가죠
쌍따옴표 오류는 아닌것 같은데
목적은 n개의 이미지 중에서 m (n>=m)개를 노중복랜덤으로 뽑는겁니다
1. 저 코드를 돌아가게 하는 방법이나
2. 목적에 부합하는 다른 방법을
알려주시면 감사하겠습니다.
php가 아니라 자바여도 됩니다.
댓글을 작성하려면 로그인이 필요합니다.
답변 1개
답변을 작성하려면 로그인이 필요합니다.
로그인
어떻게 된 일일까요..