Hoping someone can tell me what I'm doing wrong here;
Have a string which looks something like;
PHP Code:<log-entry>1001377804|22851|5|DATA_WARNING|Tue Sep 25 00:30:04 2001|The Calculation returned 1 for transaction id = 1668993</log-entry>
<log-entry>1001377804|22851|5|DATA_WARNING|Tue Sep 25 00:30:04 2001|The Calculation returned 1 for transaction id = 1668993</log-entry>
<log-entry>1001377804|22851|5|DATA_WARNING|Tue Sep 25 00:30:04 2001|The Calculation returned 1 for transaction id = 1668993</log-entry>
etc.
Every line is basically the same format and has markers so that it's real easy to break into arrays in PHP.
Now here's what I'm doing to it ( the string is called $catfile )
The problem is this only returns the first line of the string $catfile.PHP Code:if ( ereg ( "<log-entry>", $catfile ) ) {
$catfile = ereg_replace ( "</log-entry>", "", $catfile ); // Remove the end of line tag
}
$catfile = explode ( "<log-entry>", $catfile ); // Break into an array using the start of line tag
while (list ($key, $line) = each ($catfile)) { // Now pull out each line one by one into $line
$line = explode ( "|", $line ); // And break up $line using the | character
echo ( "<p>" . $line[4] . $line[3] . $line[5] . "</p>"); //Display the desired elements of one line
}
The problem seems to lie with exploding $line because if I simply output $line of each element of $catfile, without breaking it up first, I get all the origional string back.
Can someone tell me what the problem is here?






Bookmarks