What are the differences between ftp_nlist and ftp_rawlist functions in PHP and when should each be used?

The main difference between ftp_nlist and ftp_rawlist functions in PHP is the format of the output they provide. ftp_nlist returns an array of filenames in a directory, while ftp_rawlist returns a detailed list of files and directories with additional information such as permissions, owner, group, size, and timestamp. ftp_nlist should be used when you only need a simple list of filenames in a directory, while ftp_rawlist should be used when you need more detailed information about the files and directories in a directory.

// Using ftp_nlist function
$ftp_server = 'ftp.example.com';
$ftp_user = 'username';
$ftp_pass = 'password';

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);

$files = ftp_nlist($conn_id, '/path/to/directory');

foreach ($files as $file) {
    echo $file . "\n";
}

ftp_close($conn_id);
```

```php
// Using ftp_rawlist function
$ftp_server = 'ftp.example.com';
$ftp_user = 'username';
$ftp_pass = 'password';

$conn_id = ftp_connect($ftp_server);
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);

$list = ftp_rawlist($conn_id, '/path/to/directory');

foreach ($list as $line) {
    echo $line . "\n";
}

ftp_close($conn_id);