market.php Performance improvement. Smarter queries and array referencing. Fix #264

This commit is contained in:
Znote
2017-01-06 00:02:24 +01:00
parent 098efa6591
commit ce043006ed
2 changed files with 10 additions and 45 deletions

View File

@@ -1,21 +1,4 @@
<?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'
@@ -28,22 +11,4 @@ function getItemList() {
$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;
}
}
}
}