<?xml version="1.0" encoding="utf-8"?>
<items>
<item>
<title>This is title1</title>
<desc>This is desc1</desc>
<image></image>
<tudou></tudou>
</item>
<item>
<title>This is title2</title>
<desc>This is desc2</desc>
<tudou>55362137</tudou>
</item>
<item>
<title>This is title3</title>
<desc>This is desc4</desc>
</item>
</items>
here's my php code:
<div class="nav">
<ul>
<?php
$xml = simplexml_load_file('post.xml');
//print_r($xml);
foreach($xml->item as $key=>$item )
{
echo <<<HTML
<li>
<div class="published">
<span class="day">13</span>
Sep 2010
</div>
<div class="summary">
<a href="#slide-$key">
<h3>$item->title</h3>
</a>
</div>
</li>
HTML;
}
?>
</ul>
</div>
after php render the page,the <a href="#slide-$key">
return <a href=#slide-item>
.
I want $key get the number of which ,
so how to get ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…