It looks like you're in luck - the system generating this feed is apparently combing fields from a database with "standard" text to make an English language description.
The way I would go about this would be to use a sequence of explode() calls on the known text; (which splits the text into an array); use the first element as the field that you're looking for, and the second as the input to the next itteration. Here's sort of how it would work:
PHP Code:
<?php
$fields = array();
$record = array();
// start with the initial description in fields[1] for consistency
$fields[1] = "Sony Eric. K750i for 0.00 when you connect to Orange Off Peak 1000 Crossnet .With this offer you get £160 Cashback";
// get handset
$fields = explode("for ",$fields[1]);
$record["handset"] = trim($fields[0]);
// get price
$fields = explode("when you connect to ",$fields[1]);
$record["price"] = trim($fields[0]);
// get tariff
$fields = explode(".With this offer you get ",$fields[1]);
$record["tariff"] = trim($fields[0]);
// get bounty (which is what's left, if anything)
$record["bounty"] = trim($fields[1]);
// display the extracted record
print_r($record);
?>
In the above script, you end up with $record holding an associative array of the fields parsed out of the description. print_r() is a built in PHP function to display the contents of such an array. The above code outputs something like this:
Array
(
[handset] => Sony Eric. K750i
[price] => 0.00
[tariff] => Orange Off Peak 1000 Crossnet
[bounty] => £160 Cashback
)
All you need to do now is turn the above code into a function which accepts the description as input and returns $record and you should be in business. If you don't have the PHP code to read your source file line by line there are plenty of examples on fgets() and fgetcsv() pages at php.net. Please note that it will be quite easy to fool the above example code; so you would be wise to include validation on the output to ensure that it makes sense before use.
Bookmarks