title: how can I run for loop 4 times
body: <p>I have an array that I have counted and it equals 4. That is what it should equal. Now I want the foreach loop inside the for loop to only run 4 times. As it stands, I am getting to many results. Below is my latest attempt that does not work. </p>
  
  <pre><code>    $networks = array();
      $networks = ! empty( $instance['networks']) ? $instance['networks'] : '';
      $size = count($networks); //size equals 4
  
      for($i = 0; $i &lt;= $size; $i++){
          foreach ( $this-&gt;networks as $key =&gt; $value ) {
              $network_names[ $key ] = $value['class'];
          }
       $i++;
      }
  </code></pre>
  
  <p>the networks array is populated from a WordPress widget that has a repeating field section. The section allows the user to set social media icons. I currently have 4 social media icons set. On the front end, the page shows every social media icon available even though there are only 4 set. So I am trying to get the nested foreach loop to only run 4 times. </p>