테스트 사이트 - 개발 중인 베타 버전입니다

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개

채택된 답변
+20 포인트
리자
리자 Expert
11년 전
위 코드를 테스트하니 제대로 실행이 되는것 같습니다.
어디가 문제인지요?
로그인 후 평가할 수 있습니다

답변에 대한 댓글 1개

a
april44
11년 전
분명 화면에 마지막 몇 개의 문자만 ';}?> 이렇게 뜨던데.
어떻게 된 일일까요..

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인