PHP: Value won't increment for some reason
<pre><code>$blogDir = 'blog/';
$blogDirHandle = opendir( $blogDir );
$checkingFile = '';
$number = 0;
$codeNumber = '-'.$number.'-';
if( $blogDirHandle = opendir( 'blog/' ) )
{
    while( false !== ( $checkingFile = readdir( $blogDirHandle ) ) ) 
    {
        if( $checkingFile != '.' &amp;&amp; $checkingFile != '..' &amp;&amp; !is_dir( $blogDir.$checkingFile ) &amp;&amp; false !== strpos( $checkingFile, $codeNumber ) )
        {
            $number++;
            $codeNumber = '-'.$number.'-';
        }
    }
closedir( $blogDirHandle );
}
</code></pre>

<p>The code above is supposed to check, if $blogDir has a file that begins with the current $codeNumber. If it does, then increment $number ( thus changing $codeNumber ), and then loop the check until there's no more files that start with the $codeNumber.
After this, I make multiple files, which are named with the new $codeNumber.</p>

<p>But for some reason it does not work.</p>

<p>If I have only one file in the directory, called -0-filename.php, it does increment the value, and the next file I create has -1- as it's prefix. But after creating the second file, it won't increment $number. It just makes duplicate-prefix-having files ( i.e. -0-filename.php, -1-othername.php, and -1-thirdname.php )</p>

<p>Any help?</p>
