如何生成HTML文件的數量取決於數組的長度PHP如何生成HTML文件取決於數組的長度PHP
我有一個XML文件。
<books>
<book x="1" y="2">
<name x="5" y="12">Java</name>
<author x="8" y="16">Rao</author>
</book>
<book x="12" y="20">
<name x="5" y="12">Php</name>
<author x="5" y="12">Naidu</author>
</book>
<book x="19" y="29">
<name x="25" y="22">Xml</name>
<author x="25" y="12">Gowda</author>
</book>
</books>
我已經使用php將它轉換爲數組。
我有標準的html文件,即模板。
<body>
<div id="books" style="float:right; position:absolute; left: 199px; top: 245px;">
<div id="book" style="float:right; position:absolute; left: 199px; top: 245px;">
<div id="name" style="float:right; position:absolute; left: 199px; top: 245px;"></div>
<div id="author" style="float:right; position:absolute; left: 199px; top: 245px;"></div>
</div>
</div>
</body>
基於陣列legth,我需要生成與DIV這是目前在數組內的動態值的那些許多HTML文件。 在這裏,我需要生成3個html文件(因爲我有3本書元素)。如何通過使用數組生成html文件。
陣列是這個樣子:
Array
(
[book] => Array
(
[0] => Array
(
[name] => Java
[author] => Rao
[@attributes] => Array
(
[x] => 1
[y] => 2
)
)
[1] => Array
(
[name] => Php
[author] => Naidu
[@attributes] => Array
(
[x] => 12
[y] => 20
)
)
[2] => Array
(
[name] => Xml
[author] => Gowda
[@attributes] => Array
(
[x] => 19
[y] => 29
)
)
)
)
什麼是PHP數組是什麼樣子?並且請停止使用內聯CSS。 – PeeHaa
你的模板裏面包含'books' div和'book' div。所以它是整個你的xml結構的模板?所有的書都應該在你的html模板中?或者,html模板是針對一本書的,您需要爲每本書生成文件? –
我需要每本書的HTML模板。不是洞頁。在整個html頁面中,我需要將這些鏈接顯示爲標籤。 – Daya