title: Running a loop that has a function inside it
body: <p>I have a problem trying to run a code inside the loop, my loop consist of a function.</p>
  
  <p>Here is my coding:</p>
  
  <pre><code>$new = array(1,2,3,4);
  for($i=0;$i&lt;=3;$i++){
  $val = $new[$i];
  
  
  
  function myfunction($value) {   
      //Do something
  }
  
  echo $val;
  }
  </code></pre>
  
  <p>The problem is the code outputs only the 1st value in my array. I am very confused, am I not suppose to declare a function inside the loop?</p>