Could anyone please help me. I am getting the error as pasted below. I also have pasted the code itself.
What I am trying to do is read in 2 text files and merge them into 1. Both files has the same field property_ref for which I should be able to link the records. The 2nd text file actually can contain the property ref more4 than once as it hold internal house pics.
Error
Warning: Invalid argument supplied for foreach() in C:\apache\htdocs\pl\test.php on line 36
Code
<?php
$results = array();
$file = file("file1.txt");
foreach($file as $f) {
$data = explode("¦",$f);
$results[$data[0]] = array("location" => $data[1], "price" => $data[2], "main_pic" => $data[3], "bullet1" => $data[4], "bullet2" => $data[5], "bullet3" => $data[6], "bullet4" => $data[7], "bullet5" => $data[8], "bullet6" => $data[9], "bullet7" => $data[10], "bullet8" => $data[11]);
}
$file = file("file2.txt");
foreach($file as $f) {
$data = explode("¦",$f);
$results[$data[0]]['image'][] = $data[1];
}
?>
<?php
foreach($results as $key => $value) {
?>
<table border="1"
<tr>
<td><?php echo $key; ?></td>
<td><?php echo $value['location']; ?></td>
<td><?php echo $value['price']; ?></td>
<td><?php echo $value['main_pic']; ?></td>
<td><?php echo $value['bullet1']; ?></td>
<td><?php echo $value['bullet2']; ?></td>
<td><?php echo $value['bullet3']; ?></td>
<td><?php echo $value['bullet4']; ?></td>
<td><?php echo $value['bullet5']; ?></td>
<td><?php echo $value['bullet6']; ?></td>
<td><?php echo $value['bullet7']; ?></td>
<td><?php echo $value['bullet8']; ?></td>
<?php
foreach($value['image'] as $i) {
?>
<td><?php echo $i; ?></td>
<?php
}
?>
</tr>
</table>
<?php
}
?>