Question: How would I write a foreach loop that starts at a specific point and goes until it reaches the end of the file? More details:

How would I write a foreach loop that starts at a specific point and goes until it reaches the end of the file?

More details: I am working on a program that takes form input and saves it into a text file. I then display the submitted data in a table format (don't ask, it's a homework requirement) and can allow for updates. Each update is then appened to the end of the text file. I'm having trouble figuing out how to display this.

///////Here is the foreach loop I want to use to display the updates. I know the updates would start at index 8, but there's no max limit so I'm not sure how to replicate the array.length function in this format. ////////

//display updates, if any foreach (array_slice($BugReports, 8) as $FileName) { if (($FileName != ".") && ($FileName != "..")) { $Report = file($Dir . "/" . $FileName); echo '

'; echo '

Update

'; echo ''.htmlentities($Report[i]).''; echo '

'; } }

///////Here is all of the php code for the page. I've included an image of the output since you won't be able to replicate it all on your end (There's three other php files tied into all this). ////////

Bug Reports Update

//display updated report $Dir = "submissions"; if (is_dir($Dir)) { $BugReports = scandir($Dir); echo "

"; foreach ($BugReports as $FileName) { if (($FileName != ".") && ($FileName != "..")) { $Report = file($Dir . "/" . $FileName); echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } } //display updates, if any foreach (array_slice($BugReports, 8) as $FileName) { if (($FileName != ".") && ($FileName != "..")) { $Report = file($Dir . "/" . $FileName); echo ''; echo ''; echo ''; echo ''; } } echo '

Bug Description

'.htmlentities($Report[0]).'

Product Name

'.htmlentities($Report[1]).'

Product Version

'.htmlentities($Report[2]).'

Type of Hardware

'.htmlentities($Report[3]).'

Operating System

'.htmlentities($Report[4]).'

Frequency of Occurrence

'.htmlentities($Report[5]).'

Proposed Solution

'.htmlentities($Report[6]).'

Update

'.htmlentities($Report[8]).'

'; echo '

Return to bug list, OR add another update.

'; echo "


"; }

?>

How would I write a foreach loop that starts at a specific

Bug Reports Update Bug Description Product Name Product Version Type of Hardware Operating System Frequency of Occurrence Proposed Solution Return to bug list, OR add another update

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!