1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

[SOLVED] How to list all yaml config keys?

Discussion in 'Development' started by TheDiamondYT, Apr 6, 2017.

  1. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    So i have a yaml config here each key is a randomly generated UUID. I need to list those values using foreach (as ive done here).

    Code:
    uuid:
      desc: hey
    uuid2:
      desc: bye
    
    where uuid and uuid2 are the keys and desc are the values

    PHP:
    foreach($this->fdata->getAll() as $facs) {
        
    $faction = new Faction;
        
    $faction->setTag($facs["tag"], false);
        
    $faction->setDescription($facs["desc"] ?? ""false);
    }
    I can get the values of each UUID key by using
    Code:
    $facs["value"]
    but i cant get the actual UUID. Ive tried just using $facs but since its an array i get an error.

    Im sure its really simple and im just being dumb, but might as well ask.
     
    Last edited: Apr 7, 2017
  2. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Bad, hacky, messy. This is how it's supposed to be done.
    PHP:
    $config yaml_parse_file($this->getDataFolder()."config.yml");
    $keys array_keys($config);
     
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    It is not capital offence to use Config...
     
    Jack Noordhuis and TheDiamondYT like this.
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    I never said that, though I meant it :3
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.