Am trying to get my script to read in a directory and search for a a file, if the file doesnt exist it should print"that it doesn't exist" then add Notinfolder in an array. Please assist
<?php
$connection = ftp_connect($server);
$login = ftp_login($connection, $ftp_user_name, $ftp_user_pass);
if (!$connection || !$login) { die('Connection attempt failed!'); }
echo "Connected"."<br>";
$newcontents = ftp_chdir($connection, 'public_html');
$newcontents = ftp_nlist($connection, ".");
$cart = array();
$datedone=date("m.d.y");
foreach ($newcontents as $v){
if($v == "test1.zip"){
echo "True";
$cart[0]="test1.zip";
break;
}
elseif ($v<>"test1.zip")
{
echo "Test1 doesn't exist";
$cart[0]="Failed:".$datedone;
break;
}
}
echo "<br>";
print_r(array_values($cart));
ftp_close($connection);
?>