I need to be able to store data formatted like this: Code: Factions: [ Test1:[Leader: Test, Officers: [Me, You], Members: [Other, People]], etc., etc. ] What is the best data storage format (YAML,ENUM, etc.) and how should I go about storing/retrieving it? Thanks in advance!
Ezpz, PHP: /** @var Config $config */$assoc = [ "Test" => [ [ 1 => "Hello there", 2 => Item::get(Item::STONE, 0, 16) ]];//Saving.$config->set("assoc", $assoc);$config->save();//Retrieving$array = $config->get("assoc");//It's the same way you save / return strings.//Most would go with serialization if the array is big (just to save time and memory, I could be wrong).//Saving$config->set("assoc", serialize($assoc));$config->save();//Retrieving$array = $config->get("assoc");$array = unserialize($array);
I have no idea how much data will be stored by a server owner. However, now that I think about it, I doubt it would be large enough to need YAML.
Each thing has it's own purpose and I don't think YAML's purpose is to store data, I think it's more like an easily managable configuration file. For storaging stuff it is a better idea to use databases, for example: SQLITE3, MySQL, MySQLi, and many others to mention. If there isn't really much to store, you can save that data in a JSON compressed file.
Well, not MySQL, but you can always use a SQLITE3 database. If you did not know, every pocketmine server comes with one of "those".
If you are storing strings, go with JSON. When I used YAML, the line breaks did not save up whereas in JSON format, it did. I mainly use .sl (Config::SERIALIZED) format as it maintains the original code. Do not store serialized (serialize()) data in JSON. It is useless. Use json_encode() and json_decode() instead of serialize() and unserialize() if you're going for JSON