mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-29 10:49:23 +02:00

* Improve itemlistparser. Remove ugly cache file * Convert item id to int, remove items variable
35 lines
628 B
PHP
35 lines
628 B
PHP
<?php
|
|
|
|
/* Returns a PHP array $id => 'name'
|
|
$items = getItemList();
|
|
echo $items[2160]; // Returns 'Crystal Coin'
|
|
*/
|
|
|
|
function getItemList() {
|
|
return parseItems();
|
|
}
|
|
|
|
function getItemById($id) {
|
|
$items = parseItems();
|
|
if(isset($items[$id])) {
|
|
return $items[$id];
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function parseItems() {
|
|
global $config;
|
|
|
|
$items = simplexml_load_file($config['server_path'].'/data/items/items.xml');
|
|
$out = array();
|
|
|
|
// Create our parsed item list
|
|
foreach ($items->children() as $item) {
|
|
if ($item['id'] && $item['name'] != NULL) {
|
|
$out[(int)$item['id']] = (string)$item['name'];
|
|
}
|
|
}
|
|
|
|
return $out;
|
|
}
|