
Tutaj dam przykład:
Mam plik houses.xml:
Kod
<house name="Great Street I">
<tiles fromx="137" fromy="29" fromz="7" tox="143" toy="31" toz="6"/>
</house>
<house name="Great Street II">
<tiles fromx="145" fromy="29" fromz="7" tox="151" toy="31" toz="7"/>
</house>
<house name="Great Street III">
<tiles fromx="155" fromy="29" fromz="7" tox="159" toy="32" toz="7"/>
</house>
<house name="Great Street IV">
<tiles fromx="165" fromy="33" fromz="7" tox="169" toy="39" toz="7"/>
</house>
<house name="Upper Street I">
<tiles fromx="155" fromy="29" fromz="6" tox="163" toy="33" toz="6"/>
</house>
<tiles fromx="137" fromy="29" fromz="7" tox="143" toy="31" toz="6"/>
</house>
<house name="Great Street II">
<tiles fromx="145" fromy="29" fromz="7" tox="151" toy="31" toz="7"/>
</house>
<house name="Great Street III">
<tiles fromx="155" fromy="29" fromz="7" tox="159" toy="32" toz="7"/>
</house>
<house name="Great Street IV">
<tiles fromx="165" fromy="33" fromz="7" tox="169" toy="39" toz="7"/>
</house>
<house name="Upper Street I">
<tiles fromx="155" fromy="29" fromz="6" tox="163" toy="33" toz="6"/>
</house>
A teraz skrypt pobiera informację z pliku i wyświetla nazwę, ilość kratek(o tym za moment) i cenę(poniżej).
Na ilość kratek składa się wzór:
Cytat
<tiles fromx="155" fromy="29" fromz="6" tox="163" toy="33" toz="6"/>
Czyli:
tox minus fromx, toy minus fromy, toz minus fromz+1
teraz wyniki działań mnożymy i wychodzi nam liczba kratek a skrypt to wyświetli.
Cenę obliczamy: liczba kratek razy $cena która zdefiniowana jest w config.php.
Pamiętać że to jest jeden domek a skrypt ma wyświetlić wszystkie. Więc może punktem oddzielającym jeden domek od drugiego będzie tag </house> ? Nie wiem. Wasza wola. Aha, no i żeby była zmienna na ścieżkę do tego pliku

Oto kod:
<?php include ('top.inc.php');?> <?php include 'config.php'; ?> <? $dir = 'sciezka'; //localization to folder data in ots echo '<table align="left"><tr><th align="left">Name:</th><th>Tiles</th><th>Price</th><th align="left">Owner</th></tr>'; $i = 0; foreach($tags as $tag) { $i++; $name[$i] = $temp[1]; } $fx = $temp[1]; $fy = $temp[1]; $fz = $temp[1]; $tx = $temp[1]; $ty = $temp[1]; $tz = $temp[1]; } $tiles[$i] = $tiles[$i] + (($tx - $fx) * ($ty - $fy) * ($tz - $fz + 1)); else $tiles[$i] = ($tx - $fx) * ($ty - $fy) * ($tz - $fz + 1); } } for ($a=1; $a<$i; $a++) { $cena = $tiles[$a] * 250; //you can change 250 to count of gps for one sqm if ($cena > 1000) { $cena = $cena / 1000; $cena = $cena.'k'; } else $cena = $cena.' gp'; foreach($just as $jus) { $nick = $tem[1]; } $owner = '<b>Nobody</b>'; else $owner = $nick; } } print '<tr><td>'.$name[$a].'</td><td align="center">'.$tiles[$a].'</td><td align="center">'.$cena.'</td><td align="left">'.$owner.'</td></tr>'; } ?> <?php include ('menu.inc.php');?>
Jeżeli ktoś nie rozumie to mu wytłumacze
