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

Get all files

Discussion in 'Development' started by xXNiceAssassinlo YT, Jun 16, 2018.

  1. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    How do I get all files on /players/<player.name>
     
  2. BLOCKSTORM

    BLOCKSTORM Witch

    Messages:
    67
    PHP:
    scandir($this->getDataFolder "/../players");
     
  3. byyEmirhanWSD

    byyEmirhanWSD Witch

    Messages:
    50
    GitHub:
    EmirhanWSD
    Use scandir function
     
  4. Pab45O

    Pab45O Spider Jockey

    Messages:
    37
    GitHub:
    Pab450
    PHP:
    if(is_dir($this->getServer()->getDataPath()."players")){
                
    $dirPath $this->getServer()->getDataPath()."players";

                foreach(
    scandir($dirPath) as $object){
                    
    $explode explode("."$object);

                    if(
    $explode[1] == "dat"){
                        
    var_dump($explode[0]);
                    }

                }

            }
     
  5. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Can I do
    PHP:
    $dir->get("coins");
     
  6. BLOCKSTORM

    BLOCKSTORM Witch

    Messages:
    67
    No, you have to scandir the directory, then make a foreach loop for the files in the array and then you can parse the files and get the values from it.
     
  7. Az928

    Az928 Baby Zombie

    Messages:
    140
    GitHub:
    theaz928
    PHP:
    $files glob("path/to/folder/*.dat");
    // The $files var will contain array of file paths with extension .dat
     
  8. Pab45O

    Pab45O Spider Jockey

    Messages:
    37
    GitHub:
    Pab450
    It return the access path of the files in an array, it's not great..
     
  9. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    It is a very inefficient task to open a large number of files to get little data per file. Create an index file if you need to do this frequently. An SQLite3 database is a good option to do so.
     
    senyugamer and Pab45O like this.
  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.