Something similar I am having problems with.
I want to test the array for a condition and if true then to just drop it "$parts[3] and the next "$parts[4]" completely and continue on at the next value.
<?php
// Open the file
$i=0;
$loc = fopen("test.txt","r");
while ($line = fgets($loc,4096)) {
$parts = preg_split("!\s!",$line, -1, PREG_SPLIT_NO_EMPTY);
echo "Position: " . $parts[0] . "<br />";
echo "Car #: " . $parts[1] . "<br />";
echo "Laps: " . $parts[2] . "<br />";
//This is the IF I am having troubles with. Maybe I need more?
if($parts[3] == "DNS") { "Insert function to drop it and [4] completely and continue"};
echo "Time: " . $parts[3] . "<br />";
echo "First Name: " . $parts[4] . "<br />";
echo "Last Name: " . $parts[5] . "<br><br />";
?>
The file I am trying to read has data formatted as follows
1 2 7 5:26.33 Steve Ewing
2 3 7 5:26.51 Allen Ewing
-- 4 --- DNS --- Reuban Wray
3 1 7 5:28.56 Mike Lee
4 7 3 2:56.92 Daniel Dillard
-- 4 --- DNS --- Reuban Wray
Everything above is cool until it hits the DNS part which has 7 vars instead of 6 and throws the rest of the loop into a weird offset and populates my database with garbage.
The other part of the problem once I get this solved is how to delete like the first 3 lines of the file because I don't need them at all and then look for certain text and start the loop from there.....but that is a whole different beast that I can tackle after this part.
Any help would be greatly appreciated as I am a severe n00b at this.
Thanks,
Dave