title: Can't get glob to find all files not starting with ~
body: <p>I have writen the following function to recursively find all files not starting with ~.  But it doesn't work.  In fact it only seems to find those that do start with ~</p>
  
  <pre><code>function rfl($dir) {
      $search=$dir."[^~]*";
      echo "searching for: $search&lt;br/&gt;";
      $search=glob($search);  //find every file and directory not starting with ~.  directories are returned with / afterwards
      $list=array();
      foreach ($search as $file) {
          if (is_dir($file)) {
              $list=array_merge($list,rfl($file.'/'));    //recursively search for valid files in directories
              echo 'D: ' . $file.'&lt;br/&gt;';
          } else {
              $list[]=$file;                          //add files to list
              echo 'F: ' . $file.'&lt;br/&gt;';
          }
      }
      return $list;
  }
  print_r(rfl('code/'));
  </code></pre>
  
  <p>returns </p>
  
  <pre><code>searching for: code/[^~]*
  searching for: code/~private/[^~]*
  D: code/~private
  Array ( )
  </code></pre>
  
  <p>Here is the fixed function using Clayton's answer:</p>
  
  <pre><code>function rfl($dir) {
      $search = preg_grep('!^'.$dir.'[^~]!', glob($dir.'*')); //find every file and directory not starting with ~.  directories are returned with / afterwards
      $list=array();
      foreach ($search as $file) {
          if (is_dir($file)) {
              $list=array_merge($list,rfl($file.'/'));    //recursively search for valid files in directories
          } else {
              $list[]=$file;                          //add files to list
          }
      }
      return $list;
  }
  </code></pre>