Im trying to copy variable contents out to an html file, but Im having a problem where if the field is blank it still copies the empty variable string.
Heres the code:
<?
include("conf.php");
$textarea[1] = "$sent1";
$textarea[2] = "$sent2";
$textarea[3] = "$sent3";
$textarea[4] = "$sent4";
$textarea[5] = "$sent5";
$textarea[6] = "$sent6";
$textarea[7] = "$sent7";
$textarea[8] = "$sent8";
$textarea[9] = "$sent9";
$textarea[10] = "$sent10";
$textarea[11] = "$sent11";
$textarea[12] = "$sent12";
$textarea[13] = "$sent13";
$textarea[14] = "$sent14";
$counttextareas = count($textarea);
$array = array();
FOR($i = 1; $i <= $counttextareas; $i++) {
array_push($array, $textarea[$i]);
$today = date("M-d-Y");
$filename = $today.".ticker_archive.html";
$path = "C:/Inetpub/wwwroot/bna-intranet/ticker_archive/";
$somecontent = "<ul><li><font color=\"$fontcolor\">".$textarea[$i]."</li></ul></font>";
// Let's make sure the file exists and is writable first.
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "<b>Success</b>, wrote (". strip_tags($somecontent) .") to file ($filename)<br />";
fclose($handle);
}
echo "<br /><br /><br /><br />";
if (!copy($filename, $path.$filename)) {
echo "Failed to copy $filename...<br />\n";
} else {
echo "Your file has been copied too $path<br /><br />\n"; }
if (file_exists($filename))
{
unlink($filename);
}else{
echo ("$filename could not be found!");
}
?>
The first screenshot is a success msg, where u can see the empty ( )
The second screenshot is the html file and the empty bullets.
Whats wrong here? What code do I need?