Hi All I am trying to find out the best way to capture the var_dump($contents) on line 29. I am think array? but I don't know how many string elements the array is returning.
This is the output via var_dump($contents);
array (size=45)
0 => string '.' (length=1)
1 => string '..' (length=2)
2 => string 'logs' (length=4)
3 => string 'index.html' (length=10)
4 => string 'executable' (length=10)
5 => string 'watkinshire' (length=11)
6 => string '.bash_history' (length=13)
7 => string 'beaumont_hire' (length=13)
8 => string 'aircon_london' (length=13)
9 => string 'aircon_london_test' (length=18)
10 => string '.htpasswd' (length=9)
11 => string 'abacustree' (length=10)
12 => string 'abacustree_test' (length=15)
13 => string 'watkins' (length=7)
14 => string 'plasticsmoulder' (length=15)
15 => string 'plasticsmoulder_test' (length=20)
16 => string 'beaumont_test' (length=13)
17 => string 'filestore' (length=9)
18 => string 'admin' (length=5)
19 => string 'sandbox' (length=7)
Any help would be appriciated
Thanks
David
<?php
// set up basic connection
$ftp_server = "servernamexxxx";
$conn_id = ftp_connect($ftp_server);
// login with username and password
$ftp_user_name = "name";
$ftp_user_pass = "password";
//connecting
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_pasv($conn_id, true);
// check connection or error message
if ((!$conn_id) || (!$login_result)) {
echo "FTP connection has failed!";
echo "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $ftp_user_name";
}
// set up basic connection
$conn_id = ftp_connect($ftp_server);
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// get contents of the current directory
$contents = ftp_nlist($conn_id, ".");
var_dump($contents);
ftp_close($conn_id);
?>