Have you tried looking if the (file name C before the extension) is present at the leftmost part of B
I would do that as follows:
// filenames are stored in $stringC and $stringB
// to make things simpler in the line below, it is assumed that $stringC does NOT start with a '.' in position 0
// otherwise look for solutions at http://www.php.net/manual/
$length_filename= strppos ($stringC, '.');
$my_filename= ($length_filename = 0) ? $stringC : substr ( $stringC, 0, $length_filename) ;
$pos = strpos ($stringB , $my_filename) ;
// finding 0 is not enough to decide! see http://www.php.net/manual/
if ($pos === false) { // that's 3 = signs
// $my_filename is not part of $stringB
$it_matches = false;
} else {
// $my_filename is part of $stringB... but we are interested only if $pos is 0
$it_matches = ($pos = 0 ) ? true : false;
};
or, to use a shorter form for this last "coumpound if":
$it_matches = (($pos === false) || ($pos > 0)) ? false : true ;
Main Topics
Browse All Topics





by: RQuadlingPosted on 2005-11-11 at 01:03:05ID: 15272195
Assuming that the PROPER filename is only ever 12 characters long (12345_file01 is 12 characters), then you COULD ...
$file_c = $sDirectoryForCFiles . substr(basename($file_b), 0, 12) . '.tif'; // Assuming the extensions are fixed for a, b and c.