1

This seems like it should be easy, but nothing I've tried worked.

$glob = glob("{04-19-2017,04-20-2017,04-21-2017}/*.xml", GLOB_BRACE);

works perfectly.

But how I'm doing things is using a _GET to dynamically produce a $date variable.

I've tried...

$date = '04-19-2017,04-20-2017,04-21-2017';

// failed glob attempts
$glob = glob("{'.$date.'}/*.xml", GLOB_BRACE);
$glob = glob("{$date.}/*.xml", GLOB_BRACE);
$glob = 'glob("{' . $date . '}/*.xml"', GLOB_BRACE);

Like I said this should be super simple, but I'm running out of ideas :/

How do I get the variable in there?

Brian Bruman
  • 883
  • 12
  • 28

1 Answers1

2
$glob = glob("{$date}/*.xml", GLOB_BRACE);

or

$glob = glob('{'.$date.'}/*.xml', GLOB_BRACE);

If you put a variable between " " the variable will be used

If you put a variable between ' ' the variable will be handled as a string

What is the difference between single-quoted and double-quoted strings in PHP?

Community
  • 1
  • 1
Peter
  • 748
  • 6
  • 20
  • Thank you! And for the edits. I was going to comment, but then you made the edit with the correct answer for me. original `$glob = glob("{$date}/*.xml", GLOB_BRACE);` did not work at all but `$glob = glob('{'.$date.'}/*.xml', GLOB_BRACE);` works perfectly and makes sense now that I look at it. Thanks again. – Brian Bruman Apr 22 '17 at 01:23
  • 1
    Yes of course. Can't accept before 10 minutes though :) – Brian Bruman Apr 22 '17 at 01:29