this is driving me nuts.. as far as i can see the code should be working, but for some reason it doesn't.
// Let's see if $page is odd
$odd_flag = $page & 1;
// Set location of pdf's and then open directory
$dir = 'pdf';
$d = opendir($dir);
while (false !== ($file = readdir($d))) {
if ($file == "." || $file == "..") continue;
// Let's see if this is a file or a directory
if (is_file($file)) {
// Check if $page is even or odd
if ($odd_flag) {
// $page should precede the underscore
if (preg_match('/' . $page . '\_[02468]+\.pdf/', $file)) {
$rString = "&link=".$file."#viewrect=".$left.",".$top.",113.2,113.2";
echo "check 1 <br>";
}
} else {
//$page should follow the underscore
if (preg_match('/[13579]+\_' . $page . '\.pdf/', $file)) {
$rString = "&link=".$file."#viewrect=".$left.",".$top.",113.2,113.2";
echo "check 2 <br>";
}
}
} else {
echo "NO GO! <br>";
}
}
// Close the directory
closedir($d);
The script always straight to the NO GO! else statement. $file never gets populated. i don't know why.
thanks in advance for any help