jord49 jord49 - 6 months ago 3x
PHP Question

Change foreach loop to a for loop

I'm quite new to PHP. How can I change this foreach loop to only loop twice?


foreach($results as $row):



Try this code, you just need a counter variable, initialize your counter variable from zero and increment it after each iteration.

    $counter = 0; 
    foreach($results as $row) {
         //your code
         if($counter == 1)