donok
donok

Reputation: 135

PHP: filename searching/matching

How would I go about searching/matching for a paticular set of a characters in a filename, for example 3XYTPRQgz.pdf is the filename, I need to search for '3XYTPRQ', then if this string is found I simply want to output 'job completed', if its not there it will be set to queued. ( I want to do this for more than one file).

My thoughts on how to do this is, (I am struggling on the matching of the string part) :

<?php
if(match("7digitnumber) //then < not sure what function to use any tips?
if file_exists($7digitnumber/filename)
{
echo "completed";
}
else
{
echo "queued";
}
?>

Thanks for any help.

Upvotes: 0

Views: 517

Answers (1)

mqchen
mqchen

Reputation: 4193

If you simply want to find out if a given string (your case "3XYTPRQ") is part of a longer string ("3XYTPRQgz.pdf") you can take a look at strstr.

Upvotes: 1

Related Questions