2

Say I have all these files in a folder:

something(34324).php
something(34).php
something(3433454546).php
something(65565).php
something(9887).php
something(4585).php // ect ect

Now I need to somehow check if any something.php file exists (ignoring the number).

so if something(a_number).php exists in the folder, return true...

Any ideas on how I'd do something like this?

salathe
  • 51,324
  • 12
  • 104
  • 132

1 Answers1

8

You can use glob(), which returns an array of directory contents matching a wildcard pattern.

$somethings = glob('something*.php');
if (!empty($somethings)) {
    // something exists
}
salathe
  • 51,324
  • 12
  • 104
  • 132