user1919
user1919

Reputation: 3938

How to use wildcard in a string in php?

I am using PHP to access some folders with a specific path starting with the letter: "C". Can I somehow use a wild character in order to get all the folders names starting with C?

For example I have three folders as: Camera, Center, Calls The sub directories of these paths are the same. How can I do something like this in PHP:

$var = "C*/folder_1/folder2/"

Upvotes: 0

Views: 452

Answers (1)

TiMESPLiNTER
TiMESPLiNTER

Reputation: 5899

You're looking for the glob() function.

var_dump(glob('C*/folder_1/folder2/'));

Upvotes: 1

Related Questions