// Connect to database $pdo = new PDO("mysql:host=localhost;dbname=myDatabase", "myUsername", "myPassword"); // Query to retrieve all users $query = $pdo->prepare("SELECT * FROM users"); // Execute the query $query->execute(); // Fetch all users $users = $query->fetchAll(PDO::FETCH_ASSOC); // Print out the users print_r($users);
// Directory to retrieve files from $directory = "/path/to/files/"; // Get all files in directory $files = scandir($directory); // Remove . and .. from the list of files $files = array_diff($files, array(".", "..")); // Print out the files print_r($files);In this example, we are using PHP's scandir function to retrieve all files in a specified directory, removing the "." and ".." entries from the list of files, and printing out the remaining files. The library used in this example is PHP's built-in functions.