[QUOTE]I'm trying to parse a file that looks like this:quote:
{ data 1 } { garbage data }
{ data 3 } { garbage data }
{ data 3 } { garbage data }
--------------------------------------------------------------------------------[/QUOTE]Sorry, I didn't realize the situation you described wasn't the actual situation.
This should work:
$lines = file($data_file);
foreach ($lines as $line) {
if ((($pos_1 = strpos($line, '{')) === false) ||
(($pos_2 = strpos($line, '}')) === false) ||
($pos_1 > $pos_2)) {
continue;
} else {
$datum = substr($line, $pos_1, $pos_2);
$data[] = trim($datum, '{}');
}
}
If not, some minor adaptations to the code should do it.