title: Checking multiple files in a directory and return bool value
body: <p>Checking a single file using the code below works.. but I have to check many files in a loop. I am working on a project that have a lots of files (around 1000). File name differs just on prefix with some breaks. It is a project using CI framework.</p>
  
  <blockquote>
    <p>Case I: using is_file() and file_exists()</p>
  </blockquote>
  
  <pre><code>&lt;?php function custom_file_exists($filePath)
     {
           if((is_file($filePath))&amp;&amp;(file_exists($filePath))){
             return 'true';
           }
           return 'false';
     }
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p>Case II: using glob()</p>
  </blockquote>
  
  <pre><code>&lt;?php function custom_file_exists($filePath) {
      $files = glob('uploads/folder/*.pdf', GLOB_BRACE);
      if (in_array($filePath, $files)) {
          return 'true';
      } else {
          return 'false';
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Here is the part of the code that I want to work on. File check function works when passing a single filePath but fails when I do the same using following loop.</p>
  
  <pre><code>&lt;?php foreach($files as $file):
      //checking all files in loop
      $search = 'uploads/folder/'.$file-&gt;name;
      $result = custom_file_exists($search);
      echo $result;  //return 'false' even if the file is present
  
      //checking for single file
      $search1 = 'uploads/folder/filename';
      $result1 = custom_file_exists($search1);
      echo $result;  //return 'true' when file is present
  
      endforeach;?&gt;
  </code></pre>
  
  <p>I am not being able to figure out what is wrong with the code. Can someone help me out in this ?? Any ideas are appreciated. Thanks for the help.</p>
  
  <blockquote>
    <p>Var dump of glob function as requested.</p>
  </blockquote>
  
  <pre><code>&lt;?php $allfiles = glob("uploads/folder/*.pdf");
  print_r($allfiles);?&gt;
  </code></pre>
  
  <p>The result is:</p>
  
  <p>Array ( [0] => uploads/folder/file1.pdf [1] => uploads/folder/file2.pdf  [2] => uploads/folder/file3.pdf [3] => uploads/folder/file4.pdf [4] => uploads/folder/file5.pdf [5] => uploads/folder/file6.pdf [6] => uploads/folder/file7.pdf [7] => uploads/folder/file8.pdf ...... </p>
  
  <blockquote>
    <p>For the $files that I am using in loop: print_r($files) gives the following output.</p>
  </blockquote>
  
  <p>Array ( [0] => stdClass Object ( [id] => 1 [name] => file1.pdf [description] => something here [published_date] => 2016 [publish] => 1 )</p>
  
  <p>[1] => stdClass Object ( [id] => 2 [name] => file2.pdf [description] => something here [published_date] => 2016 [publish] => 1 )</p>
  
  <p>[2] => stdClass Object ( [id] => 3 [name] => file3.pdf [description] => something here [published_date] => 2016 [publish] => 1 )</p>
  
  <p>[3] => stdClass Object ( [id] => 4 [name] => file4.pdf [description] => something here [published_date] => 2016 [publish] => 1 ) ......</p>