What is the best way to check the lines of an array in PHP?

When checking the lines of an array in PHP, you can use a loop to iterate through each element of the array and check if it meets certain criteria. One way to do this is by using a foreach loop to go through each line and perform the necessary checks.

// Sample array
$array = array("line 1", "line 2", "line 3");

// Check each line in the array
foreach($array as $line) {
    // Perform checks on each line
    // For example, check if line contains a specific keyword
    if(strpos($line, "keyword") !== false) {
        echo "Line contains keyword: " . $line . "\n";
    }
}