| xXziroXx |
04-14-2008 09:52 PM |
loadIni2() - loadIni() replica
Since I couldn't get loadIni() to work, and I don't want to halt my script until I find out why, I decided to script my own version of it. Should work the exact same way loadIni() is intended too.
PHP Code:
function loadini2(file) { temp.data.loadlines(file); temp.var = new TStaticVar(); for (temp.line: temp.data) { if (temp.line.starts("[")) { this.preffix = temp.line.substring(1, temp.line.length() - 2); continue; } else if (temp.line.tokenize("=").size() < 2) continue; temp.str = temp.line.tokenize("=")[0]; temp.var.(@this.preffix).(@temp.str) = temp.line.substring(temp.str.length() + 1, temp.line.length()); } return temp.var; }
Use it with:
PHP Code:
this.var = loadIni2(path/to/file/filename.ext);
Example of .ini file:
PHP Code:
[slotA] charname=Rawr level=17
[slotB] charname=Roar level=3
this.var.slotA.charname would echo "Rawr".
|