[Solved] How to detect second occurrence of an empty line in a text file?


Assuming that $arr is the lines of the file…

$emptyLinesSkipped = 0;
foreach ($arr as $value) {
  if ('' === trim($value)) {
    if ($emptyLinesSkipped < 2) {
      $emptyLinesSkipped = $emptyLinesSkipped + 1;
      continue;
    }

    $item3 = $value;
    // and so on...
  }
}

solved How to detect second occurrence of an empty line in a text file?