ZnoteAAC/engine/function/itemparser/itemlistparser.php
Stefan Brannfjell d3807bfafe Much quicker item parser (335 items in 12ms instead of 2100ms)
Now checking if character is offline before changing gender.
Restructured Admin_shop.php, it will now show pending orders and the whole transaction log.
2014-06-17 02:35:48 +02:00

50 lines
905 B
PHP

<?php
function getItemNameById($id) {
$item_list = explode(PHP_EOL, file_get_contents('item_list.txt'));
foreach ($item_list as $items) {
$item_array = explode('@', $items);
if ($item_array[0] == $id) {
echo ucfirst($item_array[1]);
break;
}
}
}
/* Returns a PHP array $id => 'name'
$items = getItemList();
echo $items[2160]; // Returns 'Crystal Coin'
*/
function getItemList() {
$item_list = explode(PHP_EOL, file_get_contents('item_list.txt'));
$ia = array();
for ($i = 0; $i < count($item_list) - 1; $i++) {
$it = explode('@', $item_list[$i]);
$ia[(int)$it[0]] = ucfirst($it[1]);
}
return $ia;
}
function getItemIdByName($name) {
$item_list = explode(PHP_EOL, file_get_contents('item_list.txt'));
foreach ($item_list as $items) {
$item_array = explode('@', $items);
if ($item_array[1] == $name) {
echo ucfirst($item_array[0]);
break;
}
}
}