Hello,how to unset a config file like the config file look like this Family -Joe -David -Marry Then I wanna to delete "David",after delete it look like Family -Joe -Marry
Using Config->get(), you can get the "Family" (which will return an array) Then, you will want to remove "David" from the array, here's something from StackOverFlow: Then, using Config->set() (iirc), set the Family to the new array and save the config
Ya I try it but It cames to Code: Family: -Joe -David -Marry to this Code: Family 1: Joe 2: David 3: Marry
It's actually the same thing once it is parsed. But I understand why you would prefer the first one over the other. While I currently don't have an answer you're looking for. I'm here to spread propaganda. I discourage people from actually using Configs as a place to store data. It was never meant for that anyway. What I would do is, handle your raw data like you would through arrays, object properties etc. And implement load & save operations. for YAML just do: PHP: # Loading$data = yaml_parse_file('path/to/file.yaml');# Saving$data = [ 'Family' => ['Joe', 'David', 'Marry']];yaml_emit_file("path/to/file.yaml", $data); for JSON: PHP: # Loading$data = json_decode(file_get_contents('path/to/file.yaml'), true);# Savingfile_put_contents(json_encode($data, JSON_PRETTY_PRINT)); Might seem complicated and unnecessary. But really is not. If you think about it, it's a Configuration file not a database. I don't see why would you wrap an array into new class, just to change one value.
Um... I mean... Like this, example. I want to delete a value David from config. Before delete Code: Family: -Joe -David -Marry After delete Code: Family - Joe - Marry I need it like this...
PHP: $old = $config->getNested("your.array");unset($old[array_search($old, "David")]);$config->setNested("your.array", $old);$config->save();$config->reload();