User
User

Reputation: 67

How to skip second line using a for loop

I have a code snippet, which prints the output by obtaining the number of lines from a shell script using for loop.

I want to skip the second line and print the remaining lines.

$lines = explode("\n", $output);       
    for ($i = 1; $i <sizeof($lines); $i++) 
            {
                echo '<tr>';
                $columns = explode("\t", $lines[$i]);
            }

Should I not be using for loop?

Upvotes: 0

Views: 124

Answers (1)

Veshraj Joshi
Veshraj Joshi

Reputation: 3579

you need to check the number of line and make use of continue in php

for ($i = 1; $i <sizeof($lines); $i++) 
{
    if($i==2){ continue; }   
    echo '<tr>';
    $columns = explode("\t", $lines[$i]);
}

Upvotes: 1

Related Questions