How to generate HTML files depends on array length php
I have an XML file.
<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>
I have converted it into array using php.
I have standard html files i.e template.
<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>
Based on the array legth, I need to generate those many html files with dynamic values inside the div which are present in array .
Here i need to generate 3 html files (because i have 3 book elements).How can i generate the html files by using array.
array is look like this:
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
)
)
)
)
In your html template, use delimiters like real-template :
In the PHP-side, use regexp to replace data in your template :