I have a small database "Database.txt", each line of which looks something like:
rv001,Some More Cities,112.00,OK,1R: Paris2_4R: London4_6R: New York8R: Moscow10R: Rome,
I use a bit of php code to find an entry like the one above "rv001", and print an element of it out, like so:
<?php
$array2 = file("Database.txt");
foreach($array2 as $row) {
$line = explode(',', $row);
if ($line[0] == 'rv001') {
echo $line[4];
}
}
?>
Of course, "echo $line[4];" prints out the last element, which looks like:
1R: Paris2_4R: London4_6R: New York8R: Moscow10R: Rome
But I want to go further and turn that element into some html. Specifically, I'd like to extract this last element (...either using my code example above or not!), and:
1)...take out each element between the asterisks (eg, "1R: Paris", "2_4R: London", "4_6R: New York", etc)
2)...also take out the part of each element up to the colon (eg, "1R", "2_4R", etc)
3)...add "images/city" to the beginning and ".jpg" to the end of these elements from step 2 (eg, "city1R.jpg", "city2_4R.jpg", etc)
4)...draw an html table of the images URLs so extracted in step 3, with the entire element between the asterisks as at step 1 as the "alt" tag, and add a javascript "onclick" command, so it will look like:
<img src="images/city1R.jpg" alt="1R: Paris" onclick="SetImage(this.alt,this.src)">
<img src="images/city4_6R.jpg" alt="1R: London" onclick="SetImage(this.alt,this.src)">
...etc
Can someone help me out?