<!- - TASK -- Write your PHP code in in the space provided below . --> <div clas
ID: 3591135 • Letter: #
Question
<!-- TASK -- Write your PHP code in in the space provided below. -->
<div class="task">
<h2> Task : Files, arrays, and for-loops </h2>
<p> This task is to read in the contents of the file <code>List.txt</code> in to PHP. Then, you should print out each line
from the file as a paragraph element. If the line contains the string "ENG", print this out using highlight.
</p>
<div class="output">
<?php
/* Task 3: Put your code here */
?>
</div>
</div>
Explanation / Answer
$file_handle = fopen("code", "r");
while (!feof($file_handle)) {
$line = fgets($file_handle);
if(strpos($line,'ENG')){
highlight_string($line);
}
else{
echo $line;
}
}
fclose($file_handle);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.