I have a text-string looks like this:
OM Sweden:SE0007286893:SEK;2;2;0;8 END
I want to read the 8 at right before end to a constant.
My problem is that sometimes it is 8, sometimes 16, and sometimes 140
and then the textstring looks like this:
OM Sweden:SE0007286893:SEK;2;2;0;16 END
OM Sweden:SE0007286893:SEK;2;2;0;140 END
meaning END doens't always occurs in same position, how do i solve this?
I have used this code before, but it read from left to right:
Code: Select all
// make sure the file is successfully opened before doing anything else
if ($fp = fopen($myFile, 'r')) {
$content = '';
// keep reading until there's nothing left
while ($line = fread($fp, 1024)) {
$content .= $line;
$data = strstr($content,"SE");
$isin = substr($data, 0, 12);
echo "$isin <br />";
}
// do something with the content here
} else {
// an error occured when trying to open the specified file
// do something here ... ?
echo "Kunde ej öppna html-filen";
}