pulling text from a file
| From: | Richard Kurth | Date: | Fri, 21 Mar 2008 18:32:06 +0000 |
| Subject: | pulling text from a file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-271945@lists.php.net to get a copy of this message | ||
I have a text file that looks like the one below. I need to read the file into a database.
I was trying the script below but is not working can you help?
$lines = file_get_contents('clientlist1.txt');
$find="Address:";
$f= strstr($f,$find);
$separat="City:";
$ADDRESS = substr($f, 0, strpos($f,$separat));
$ADDRESS=ltrim($ADDRESS,"Address:");
$ADDRESS=trim($ADDRESS);
echo $ADDRESS;
echo "<br>";
$find="City:";
$f= strstr($f,$find);
$separat="State:";
$CITY = substr($f, 0, strpos($f,$separat));
$CITY=ltrim($CITY,"City:");
$CITY=trim($CITY);
echo $CITY;
echo "<br>";
Text File
Address: 5070 myaddress. City: mycity State: mystate Zip: 97268 County:Signers
Name: my name
Address: 3925 myaddress. City: mycity2 State: mystate2 Zip: 97268 County:Signers
Name: my name2