Skip to content
Advertisement

How to organzie data from a raw txt file with PHP [closed]

I have a raw data into a .txt file which i want to use to build a character stats out of it. Now sure if it will parse well below but i have into a textarea on my website (will leave a link below) where it is structured better than what it looks like here. Any ideas how can i put it to use with PHP? I want to use this data on a “character calculator” where people will choose a level and i want to dispaly the HP, Def, Str, Dex and all the other stats based on the level chosen. They are on the same row as the level so i was thinking either to read the level and see what’s on the row next or maybe a whole different approach. I am open to ideas

https://www.diablo-2.net/articles/mercenaries#act-1-rogues

JavaScript

Edit: I checked the suggested idea by E. Safa Tok and I did some tests using this:

JavaScript

It works!!!! Thanks a lot.

Advertisement

Answer

I wrote a piece of code to split your input to array. After that process, also you can generate JSON formatted array with json_decode function.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement