내가 여기 XML을 통해 3 후 후 모든를 이미지를 에코 싶어하는 것은 내 코드입니다 : 여기 PHP : 루프의 N 번째 반복을 어떻게 결정합니까?
<?php
// URL of the XML feed.
$feed = 'test.xml';
// How many items do we want to display?
//$display = 3;
// Check our XML file exists
if(!file_exists($feed)) {
die('The XML file could not be found!');
}
// First, open the XML file.
$xml = simplexml_load_file($feed);
// Set the counter for counting how many items we've displayed.
$counter = 0;
// Start the loop to display each item.
foreach($xml->post as $post) {
echo '
<div style="float:left; width: 180px; margin-top:20px; margin-bottom:10px;">
image file</a> <div class="design-sample-txt">'. $post->author.'</div></div>
';
// Increase the counter by one.
$counter++;
// Check to display all the items we want to.
if($counter >= 3) {
echo 'image file';
}
//if($counter == $display) {
// Yes. End the loop.
// break;
//}
// No. Continue.
}
?>
은 샘플 처음 3이 정확하지만 지금은 루프 idgc.ca/web-design-samples하지 않습니다 -testing.php
StackOverflow 코드 포맷팅 모드를 사용하십시오. 지금 코드를 읽을 수 없습니다. –
무엇이 문제입니까? 또한 텍스트 영역에서 사용할 수있는 도구를 형식화하는 방법을 살펴보십시오. –
질문을 "모든 N 번째 루프에 이미지 표시"와 같이 더 구체적으로 바꾸는 것이 좋습니다. –