This pattern doesn't appear to be correctly matching txt files with numeric names: [0-9]+.txt
.
Can someone advise me as to what I'm doing wrong?
Context: $posts = preg_grep("[0-9]+.txt", glob('posts/*.txt'));
Your expression is missing the delimiters:
'~/[0-9]+\.txt$~'
But it might just be easier to add this requirement into glob()
itself:
$posts = glob('posts/[0-9]*.txt');