mirror of
https://gitlab.com/hashborgir/d2tools.git
synced 2025-10-13 16:34:23 -05:00
SetItems working. Tesing
This commit is contained in:
53
src/D2TxtParser.php
Normal file
53
src/D2TxtParser.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
D2UniqueMaker
|
||||
GPLv2 (C) <2021> <HashCasper>
|
||||
|
||||
This file is part of D2UM.
|
||||
|
||||
D2UM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
D2UM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with D2UM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
This is a generic D2 Txt Parser
|
||||
*/
|
||||
|
||||
class D2TxtParser {
|
||||
|
||||
public $path = TXT_PATH;
|
||||
// Files specific to Unique Items
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
public function parseFile($file){
|
||||
return $this->toPHP($file);
|
||||
|
||||
}
|
||||
|
||||
function toPHP($file) {
|
||||
$file = $this->path . $file;
|
||||
$rows = array_map(function ($v) {
|
||||
return str_getcsv($v, "\t");
|
||||
}
|
||||
, file($file));
|
||||
$header = array_shift($rows);
|
||||
foreach ($rows as $row) {
|
||||
$data[] = @array_combine($header, $row);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user