Skip to content
Advertisement

Tag: ends-with

Search array of filenames for file ending with “.txt”

I have an array with filenames. I want to check if the array have a file with extension ‘.txt’. How can I do that? in_array only checks for a specific value. Answer Contrarily to other answers suggesting array_filter, I don’t return something. I just check if it exists in the array. Besides, this implementation is more efficient than array_filter because

Advertisement