如果数据是这样的,我如何从文件中读取数据。
<area shape="poly" alt="1101" coords="1735,606, 1736,606, 1737,606, 1738,606, 1739,606, 1740,606, 1741,607,
我知道如何打开文件以及如何简单地读取和存储数据,但是如何从“alt”和“coords”中提取数据,请帮帮我。
<?php
$handle = @fopen("sunset_map.map", "r");
$conn = mysql_connect("localhost","root","");
mysql_select_db("read_data",$conn);
while (!feof($handle)) // Loop til end of file.
{
$buffer = fgets($handle, 4096);
// Read a line.
// $a = $_get['alt'] ;
// $b = $_get['coords'];
// parse_str("alt = str& coords = ",$myarray);
// print_r($myarray);
list($a,$b)=explode("|",$buffer);
// list($myarray)=explode("|",$buffer);
//Separate string by the means of |
// echo $a."-".$b."<br>";
$sql = "INSERT INTO content_data (id,coords) VALUES('".$a."','".$b."')";
mysql_query($sql,$conn) or die(mysql_error());
}
?>