$outputDir = $_SERVER['DOCUMENT_ROOT'] . "/dirName";
$dir = new RecursiveDirectoryIterator($outputDir);
$rec = new RecursiveIteratorIterator($dir);
$a=3;
$b = 10;
$regex = '/Chapter[' .$a. ',' .$b. '/.html]$/';
$it = new RegexIterator($rec, $regex);
I want to read all the files which is between $a and $b.
If $a is 3 and $b is 5, then read chapter3.html, chapter4.html, chapter5.html
But $it is null. I feel that I am missing something. Can you please help?
var_dump on each statement returns
$output dir looks like
<pre class='xdebug-var-dump' dir='ltr'><small>string</small> <font
color='#cc0000'>'C:/server/httpd/Apache24/htdocs//front-page1//front-
page//subjects//maths'</font> <i>(length=73)</i>
</pre>
Directory looks good
Recursive directory iterator returns
<b>object</b>(<i>RecursiveDirectoryIterator</i>)[<i>1</i>]
<i>private</i> 'pathName' <small>(SplFileInfo)</small> <font
color='#888a85'>=></font> <small>string</small> <font
color='#cc0000'>'C:/server/httpd/Apache24/htdocs//front-page1//front-
page//subjects//maths\.'</font> <i>(length=75)</i>
<i>private</i> 'fileName' <small>(SplFileInfo)</small> <font
color='#888a85'>=></font> <small>string</small> <font
color='#cc0000'>'.'</font> <i>(length=1)</i>
<i>private</i> 'glob' <small>(DirectoryIterator)</small> <font
color='#888a85'>=></font> <small>boolean</small> <font
color='#75507b'>false</font>
<i>private</i> 'subPathName' <font color='#888a85'>=></font>
<small>string</small> <font color='#cc0000'>''</font> <i>(length=0)</i>
</pre>
Directory looks invalid
Recursive iterator iterator returns
<pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>RecursiveIteratorIterator</i>)[<i>2</i>]
What does this two mean?
Regex is
</pre><pre class='xdebug-var-dump' dir='ltr'><small>string</small> <font
color='#cc0000'>'/Chapter{0,5}\.html$/i'</font> <i>(length=22)</i>
</pre>
Regex iterator is
<pre class='xdebug-var-dump' dir='ltr'>
<b>object</b>(<i>RegexIterator</i>)[<i>3</i>]
<i>public</i> 'replacement' <font color='#888a85'>=></font> <font
color='#3465a4'>null</font>
</pre>