title: PHP Before during an If statement
body: <p>I want call a BEFORE in PHP</p>
  
  <p>my code so far:</p>
  
  <pre><code>&lt;?php
  $folder_path = $cdnurl . 'assets/' . $pid . '/';
  
  // Loop from 2 to 5
  for ($i = 2; i &lt;= 6; $i++) {
  
  if(@fopen($folder_path . $i . '/large.jpg',"r")){
  ?&gt;
  
      &lt;li&gt;&lt;a id="&lt;?php echo $i;?&gt;" href="&lt;?php echo $i;?&gt;/large.jpg"&gt;&lt;?php echo $i;?&gt;&lt;/a&gt;&lt;/li&gt;
  
  &lt;?php } else {
  break;
  }
  }?&gt;
  </code></pre>
  
  <p><strong>EDIT</strong>
  I edited the code above as it is already nested with IF and ELSE. I want it to echo. something like</p>
  
  <pre><code>&lt;ul&gt;
  &lt;li&gt;2&lt;/li&gt;
  &lt;li&gt;before&lt;/li&gt;
  &lt;li&gt;3&lt;/li&gt;
  &lt;li&gt;4&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>