i finished my script with the help of some folk here. The purpose of it was to take 100 or so .html files, each named for the date they were created in either POSIX formats or MMDDYY (for example 23dec2002.html or 040598.html) parse their names using strtotime and date "F d Y" and display them, in chronological order, in a selection menu.
Everything seems to work fine expect for the following warning.
Warning: Unexpected character in input: '' (ASCII=16) state=1 in /client/home/apq-potash/docs/prototype/press.php on line 48
here's what i've got, with 'line 48' in bold
print ("<option name=\"scanner\" value=#\">".$_POST["selection"]);
$dir = "press/"; //working directory
if ($dh = opendir ($dir)) {
$list = array();
$counter = 0;
global $scanner;
while (($scanner = readdir($dh)) !== false) {
$substr0 = substr($scanner, -5);
$length1 = strlen($scanner);
$length2 = $length1 -5;
if ($substr0 == ".html"){
$scan = substr($scanner, 0, $length2);
array_push($list, $scan);
//array_flip($list);
//print ($list[$counter]." <br>");
$counter = $counter + 1;
}
}
$counter = 0;
global $order;
$order = array($list[$counter] => $selection);
$names = array();
while (each($list) == true){
$dlength = strlen($list[$counter]);
//$scanner = readdir($dh);
if ($dlength == 6){
$month = substr($list[$counter], 0, 2);
$day = substr($list[$counter], 2, 2);
$year = substr($list[$counter], 4, 2);
$digiformat2 = "19".$year.$month.$day;
$date = strtotime($digiformat2);
array_push ($order, $date);
//next($list);
$counter = $counter +1;
} else {
$date = strtotime($list[$counter]);
array_push ($order, $date);
//next($list);
$counter = $counter +1;
}
}
$noitems = count($order);
$counter = 0;
arsort($order);
$filename = array_keys($order);
$flipname = array_flip($filename);
//print_r ($filename);
while ($counter < $noitems){
$fdate = date("F d Y", $order[$filename[$counter]]);
//$filename = next($names);
print ("<option name=\"scanner\" value=\"".$list[$filename[$counter]].".html\">".$fdate);
$counter = $counter +1;
}
}
print ("</select></form>");
$selection = $_POST["selection"];
$string = file_get_contents("press/".$selection);
$prerelease = explode('</tr>', $string);
$number = count($prerelease);
if($number == 8){
$release = strip_tags($prerelease[6], "<br>, <p>");
} elseif ($number == 7) {
$release = strip_tags($prerelease[5], "<br>, <p>");
} elseif ($number == 2) {
$release = strip_tags($prerelease[0], "<br>, <p>");
} else {
$release1 = strip_tags($string, "<br>, <table>, </table>, <tr>, </tr>, <td>, </td>");
$release = preg_replace('/<br>{3,}/', '<br><br>', $release1);}
print ($release."</div>");
any suggestions on what causes this? any other coding suggestions are greatly appreciated! thanks for taking the time!