--- Marian Briones <[EMAIL PROTECTED]> wrote:

> Hi gang
> I'm trying to export data from a pipe delimited file (|) with 
> php, trying to get away from perl entirely.
> 
> My old perl script opens the file and sticks it in an array, 
> then handles each line as a record in the database table by 
> splitting the line like this:
> 
> ($MLSNo, $Status,  $DOM, $Address, $Unit, $City, $Area, $LP, 
> $SP, $BT, $SqFt, $Bed, $Bth, $PB, $Gar, $Garno, $YrBlt, $TBMap, 
> $Acres, $LotSqFt, $HOA, $Freq) = split (/\|/,$i);
> 
> How can I achieve the same with php??????

// place the contents of a file in an array (1 line per element)
$array = file("filename");

// loop through each line of the file
foreach($array as $line)
{

list($MLSNo, $Status,  $DOM, $Address, $Unit, $City, $Area, $LP,  $SP, $BT,
$SqFt, $Bed, $Bth, $PB, $Gar, $Garno, $YrBlt, $TBMap,  $Acres, $LotSqFt, $HOA,
$Freq) = split("|", $line);

// do something with the variables

}

James
_____


James D. Keeline
http://www.Keeline.com  http://www.Keeline.com/articles
http://Stratemeyer.org  http://www.Keeline.com/TSCollection

http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks.
Spring Semester Begins in late January.  Two new class topics.


Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to