Re: pulling text from a file

From: Date: Fri, 21 Mar 2008 18:52:49 +0000
Subject: Re: pulling text from a file
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-271952@lists.php.net to get a copy of this message
Richard Kurth wrote:
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
Never mined I forgot to change $line to $f


« previous php.general (#271952) next »