php5 avoid repeated code
<p>the problem I faced with the code below is that
I couldn't avoid  repeat for loop. as I couldn't 
treat well with variable x scope.
any help would be appreciated.</p>

<pre><code>if($var &gt;0)
           {    

               if( $var&gt;3)

                {
                   $x = $var - 3;


                   for($var;$var&gt;$x;$var--)

                     {                       ||   \
                        some code;           ||====\  Repeated code.
                                             ||====/
                     }                       ||   /
                }                            ||   

              else

               {

                  $x = 0 + 0;

                  for($var;$var&gt;$x;$var--)                                  

                     {                                          

                       the same code  ;                                    

                     }                                          

                }


            }
</code></pre>
