title: Foreach txt and image files with different code blocks
body: <p>I have a gallery. I would like to glob files into. It works fine for jpg, png etc.</p>
  
  <p>Directory:</p>
  
  <p>1.jpg</p>
  
  <p>2.png</p>
  
  <p>3.jpg
  ...</p>
  
  <p>Code :</p>
  
  <pre><code>foreach ($gallery as $u)   
  { 
  echo'&lt;div class="section active" id=""&gt;'; 
  
  foreach (glob("$meno/$new/*.{png,jpg,jpeg,gif,txt}", GLOB_BRACE) as $filename) {
  
      echo '&lt;div class="slide"&gt;&lt;img class="" src="https://onlinegallery.online/'.$filename.'" /&gt;&lt;/div&gt;';  //slide
  }
  
  echo('&lt;/div&gt;');
  }
  </code></pre>
  
  <p>I would like to put a txt file to directory and create foreach for txt and image files (Some slides should be a txt files). I don't know how to do that because txt file can't be used in img src tag. It should looks something like this.</p>
  
  <p>Directory:</p>
  
  <p>1.png</p>
  
  <p>2.img</p>
  
  <p>3.txt</p>
  
  <p>4.jpg</p>
  
  <pre><code>
  $images = '&lt;img class="" src="https://onlinegallery.online/'.$filename.'" /&gt;';
  
  $txt = '&lt;div&gt;&lt;p&gt;fopen("'.$filename.'", "r");
               echo fread($txt,filesize("'.$filename.'"));
               fclose($txt); &lt;/p&gt;&lt;/div&gt;';
  
  foreach ($gallery as $u)   
  { 
  echo'&lt;div class="section active" id=""&gt;'; 
  
  foreach (glob("$meno/$new/*.{png,jpg,jpeg,gif,txt}", GLOB_BRACE) as $filename) {
  
      echo '&lt;div class="slide"&gt; 
  
  //$images or $txt files
  //i need txt and images files here
  
  &lt;/div&gt;';  //slide
  }
  
  echo('&lt;/div&gt;');
  }
  </code></pre>
  
  <p>I suppose I'm completely out, but thank you for your advice anyway.</p>