So sometime soon im going to create a plugin that uses a "cmds.yml" folder which i know how to use most of yaml things, except im not totally sure how to writ new keys. PHP: public function createCmd(string $name, string $cmd, int $time){$write = [ "$name" =>["cmd" =>["$cmd",]"time" => (int)$time,]];} And i want it to turn out something like Code: name: cmds: - cmd 1 - cmd 2 time: 2 But im not sure how to do this.
Try using yaml_emit_file(string $file, mixed $data). It'll turn the data into a yaml presentation, AKA what you're trying to do. Note that yaml_emit_file() will replace all content in the file, not add to it. If you'd like to add to it, you could yaml_parse_file(string $file) to get an array containing content from a file, then add data to that array, and finally putting it back using yaml_emit_file(string $file, array $data) again. To add things, you could then when you have that data, edit it using array syntax. For example: $data["name"]["cmds"][] = "command";