I am trying to get the foreach variable into the function and can't seem to get the function to recognize it even though I believe I have set it as a global variable.
Basically I want the script to take range of files listed in the foreach array and inspect them in the function one by one. I've omitted some of the unimportant items, please let me know if anyone has a suggestion how to get this to work:
<?php
require("MagicParser.php");
function myRecordHandler2($record)
{
$xml_file = "../testfolder/$filename";
$file_combined = "$name-$date";
$newfile_name = "$file_combined.xml";
$echo = $visitor_name;
if (file_exists("../testfolder/archive/$newfile_name")) {
echo "The file $filename exists";
} else {
if (!copy($xml_file, "../testfolder/archive/$newfile_name")) {
echo "failed to copy $file...\n";
} else {
echo "The file has been copied to $newfile_name";
}}
}
foreach (array("1, 2, 3, 4, 5") as $filename) {
global $filename;
MagicParser_parse("../testfolder/$filename.xml","myRecordHandler2","xml|test/");
}
?>
Thanks a lot for anyone's help with this!
Chris