title: Php Array Count to run script run for each reply till 3rd reply and not more than that
body: <p>I have a Forum in which adscript is displayed after every reply</p>
  <pre><code>&lt;?php if( count( $replies ) &lt;= 3 ){ ?&gt;
  
  ---- script ----
  
  &lt;?php } ?&gt;  
  </code></pre>
  <p>Earlier there was a clause that there could be maximum 3 replies per Forum post - but now that clause is changed and there are 5, 7 or 10 replies even</p>
  <p>I want to modify code so EVEN If there are more than 3 replies - then script should run after each reply till 1st 3 replies and not from 4th reply onwards</p>
  <p>I believe an array is to used likely</p>
  <pre><code>&lt;?php
  $replyCount = 0;
  foreach( $replies as $reply )
  {
  $replyCount++;
  $replyNumber = array(1, 2, 3);
  
  if (in_array($replyCount, $replyNumber)) {
  echo &quot;script&quot;;
  }
  ?&gt;
  </code></pre>
  <p>But - what the above script is doing is that</p>
  <blockquote>
  <p>Its displaying the script in all replies</p>
  <p>Its displaying script 3 times after each reply</p>
  </blockquote>
  <p>Can some one help and advise in modification so that</p>
  <blockquote>
  <p>Script should run once after each reply</p>
  <p>Script should run till 3rd reply and not more than that</p>
  </blockquote>
  <p>Pls help and advise</p>